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 (R) file path access

After asking a question on issuetracker, I’ve come to the following conclusions: On Android R, the File restrictions that were added in Android Q is removed. So we can once again access File objects. If you are targeting Android 10 > and you want to access/use file paths, you will have to add/keep the following … 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

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