Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
140 views
in Technique[技术] by (71.8m points)

android - queryIntentActivities returns zero on AVD while correct browser count on a real device

I have following code taken from How get list of web browsers in system supposed to return all browsers installed on a device.

This does not raise any error but browsersList size is zero on any AVD while works as expected on a real smart phone.

What am I missing?

Edit

Tested AVDs

Android 11 - DOESN'T WORK

Android 10 - Works

Tested Actual Devices

Android 10 - Works

Android 9 - Works

Android 8 - Works

Since I don't have an actual device with Android 11 not sure if the v11 is the problem. But it seems so.

val packageManager: PackageManager = this.getPackageManager()
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.aurl.com"))
val browsersList = packageManager.queryIntentActivities(
    browserIntent,
    PackageManager.MATCH_ALL
)
browsersList.forEach {
    val packageName = it.activityInfo.packageName
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are new changes in android 11 in package visibility.
More info you can find in documentation: https://developer.android.com/training/basics/intents/package-visibility


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...