NameNotFoundException when calling getPackageInfo on Android 11

As stated in https://developer.android.com/preview/privacy/package-visibility: Android 11 changes how apps can query and interact with other apps that the user has installed on a device. Using the new element, apps can define the set of other apps that they can access. This element helps encourage the principle of least privilege by telling the system which other … Read more

Android 11 ACTION_OPEN_DOCUMENT_TREE: set initial URI to the Documents folder [duplicate]

We will manupilate INITIAL_URI obtained from StorageManager..getPrimaryStorageVolume().createOpenDocumentTreeIntent(). if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); Intent intent = sm.getPrimaryStorageVolume().createOpenDocumentTreeIntent(); //String startDir = “Android”; //String startDir = “Download”; // Not choosable on an Android 11 device //String startDir = “DCIM”; //String startDir = “DCIM/Camera”; // replace “/”, “%2F” //String startDir = “DCIM%2FCamera”; String startDir … Read more

requestLegacyExternalStorage is not working in Android 11 – API 30

But now when I targetSdkVersion 30, this no longer seems to work That is correct. Android 11 (API 30+) requestLegacyExternalStorage=true does nothing and you can no longer “opt-out”. It was available in Android 10 to give developers a transition/grace period to be able to migrate to the scoped storage model. Option 1: Migrate data in … Read more

intent.resolveActivity returns null in API 30

This appears to be due to the new restrictions on “package visibility” introduced in Android 11. Basically, starting with API level 30, if you’re targeting that version or higher, your app cannot see, or directly interact with, most external packages without explicitly requesting allowance, either through a blanket QUERY_ALL_PACKAGES permission, or by including an appropriate … Read more

tech