Forum Discussion
Persistent preferred activity
I have implemented a function in my Android app to set Brave browser as the default browser using the provided code snippet. However, when I click on a link, it still opens in Chrome instead of Brave. Could you please review the code snippet below and let me know if there's anything I am doing wrong?
private fun setBraveAsDefaultBrowser() {
val filter = IntentFilter(Intent.ACTION_VIEW)
filter.addCategory(Intent.CATEGORY_BROWSABLE)
filter.addDataScheme("http")
filter.addDataScheme("https")
val defaultBrowser: ComponentName = packageManager.getLaunchIntentForPackage("com.brave.browser")?.component ?: return
dpm.addPersistentPreferredActivity(
AdminReceiver.componentName,
filter,
defaultBrowser
)
}
I have used addPersistentPreferredActivity()
- MoombasLevel 4.1: Jelly Bean2 years ago
Are you talking about a "normal" app or an admin (like MDM) app where it's set as device admin app on the device itself?
- SohailLevel 1.5: Cupcake2 years ago
Yes, the app is set as device admin app on the device itself. It uses DevicePolicyManager to enforce the restrictions.
- MoombasLevel 4.1: Jelly Bean2 years ago
Sorry, i took a look into that last week but haven't found anything related which could help you.
Sorry. Maybe someone else a bit more confident with this topic may be able to help you.
Related Content
- 10 months ago
- 10 months ago