androidmobile-developmentandroid-package-managerswaze

Use Intent.resolveActivity to check if Waze app is exist in device is not working in Android 13 and above


I try to use this code to check if Waze app is in device, and it always returns false even if I have Waze in my device (it's in Android 13 and above).

fun isWazeExist(): Boolean {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://waze.com/ul?q=Hawaii")) 
    intent.setPackage("com.waze")
    intent.resolveActivity(context.packageManager)?.let {
        true
    ?:let {
        false
    }
}

However if I change intent to Google Map URI and Package Name, the function is work.

fun isGoogleMapExist(): Boolean {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=bigcity")) 
    intent.setPackage("com.google.android.apps.maps")
    intent.resolveActivity(context.packageManager)?.let {
        true
    ?:let {
        false
    }
}

Solution

  • starting Android 11 you simply can't check that "some app" is installed (or obtain list of all installed apps), security and privacy reasons

    more info HERE, HERE and HERE

    just guessing why you can check presence of Maps: because it's system app, pre-installed OR is set as default (for navi?)