Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.TPStreamsAndroidPlayer"
android:enableOnBackInvokedCallback="true"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify Android version compatibility for back-invoked callback.

The android:enableOnBackInvokedCallback="true" attribute enables the new back gesture handling introduced in Android 13 (API 33). Ensure this is intentional and that the app properly handles back gestures on supported devices.


🌐 Web query:

What is the minimum Android API level required for android:enableOnBackInvokedCallback and what are the compatibility considerations?

💡 Result:

The attribute android:enableOnBackInvokedCallback is related to the new back gesture handling introduced in Android 13 (API level 33).

Minimum Android API Level

  • The minimum Android API level required for android:enableOnBackInvokedCallback is API level 33 (Android 13).

Compatibility Considerations

  • Backward compatibility:
    This attribute and the associated new back gesture API were introduced in API 33. On devices running API levels lower than 33, this attribute will not be recognized, so you should ensure fallback mechanisms or conditional code checks to maintain backward compatibility.

  • Usage in XML:
    You can use this attribute in your manifest or in your components' XML only when targeting API 33 or above. For lower API levels, it will be ignored.

  • Code Handling:
    Use runtime checks (Build.VERSION.SDK_INT >= 33) before registering callbacks or utilizing the new back gesture APIs.

  • Testing:
    Ensure you test your app on Android 13 devices (or emulators) to verify that enabling this attribute behaves as expected.

If you want, I can provide example code snippets for backward-compatible handling of back gestures. Would you like that?


Ensure API 33+ for Back-Invoked Callback and Add Fallback

The android:enableOnBackInvokedCallback="true" attribute only takes effect on Android 13 (API 33) and above. On older devices it will be ignored, so you should:

  • Verify your targetSdkVersion is set to 33 or higher and that your minSdkVersion remains appropriately low.
  • Wrap any calls to the new Back-Invoked APIs with a runtime check:
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        OnBackInvokedCallback callback = /* … */;
        getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
            OnBackInvokedDispatcher.PRIORITY_DEFAULT, callback);
    } else {
        // Fallback to traditional onBackPressed() logic
    }
  • Test on an Android 13 device or emulator to confirm the new callback is registered and behaves as expected.
🤖 Prompt for AI Agents
In app/src/main/AndroidManifest.xml at line 15, the attribute
android:enableOnBackInvokedCallback="true" requires the app to target API level
33 or higher and handle backward compatibility. Ensure your build.gradle sets
targetSdkVersion to 33 or above while keeping minSdkVersion appropriately low.
In your code, wrap any usage of the new back-invoked callback APIs with a
runtime check for API level 33 or higher, and provide fallback logic using the
traditional onBackPressed() method for lower API levels. Finally, test the app
on Android 13 devices or emulators to verify correct behavior.

tools:targetApi="31">
<activity
android:name=".MainActivity"
Expand All @@ -24,6 +25,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".PlayerActivity"
android:exported="false"
android:label="Player"
android:parentActivityName=".MainActivity" />

<activity
android:name=".DownloadsActivity"
android:exported="false"
android:label="Downloads"
android:parentActivityName=".MainActivity" />
</application>

</manifest>
Loading