Android Q support
Android Q introduces new features and APIs that you can take advantage of in your apps as well as new behaviour changes. For the application which integrated Android SDK 4 to run successfully in Android Q, the application should be changed according to the following steps.
If using PRM, the application must be granted the READ_PHONE_STATE permission in runtime. Before initialising PAK
, runtime permission requests for READ_PHONE_STATE
are necessary when all of the following conditions are true:
- The application will run on Android P devices
- The application's
targetSdkVersion
is 28 (Android P) or higher - The Operational Vault file's
EnforceSingleDeviceUniqueIDPerDeviceFlag
is set totrue
Update the
AndroidManifest.xml
for the application by addingREAD_PHONE_STATE
permission.JAVA<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Check the
READ_PHONE_STATE
permission and requestREAD_PHONE_STATE
permission in activity class.JAVAif (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[] {Manifest.permission.READ_PHONE_STATE},READ_PHONE_STATE_CODE); }
Overwrite the
onRequestPermissionsResult
method of activity to handle the request result.JAVApublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,@NonNull int[] grantResults) { //code to process the result }
Scoped storage for offline playback
Android Q changes how apps can access files on the device's external storage, such as the files stored at the path /sdcard
. Apps targeting Android Q by default can only access their app-specific directory. Google is currently specifying targeting Android SDK 28 for releasing to the store; using this target SDK, scoped storage does not get enforced, even with Android Q devices. Scoped storage is enforced when targeting SDK 29 (Q) and above, and when Google either makes that the minimum version for upgrades or the release of Android R. The apps can also use the new requestLegacyExternalStorage
manifest attribute to keep compatibility and continue to access the downloaded file after upgrading to Android Q.
<manifest ... >
<!-- This attribute is "false" by default on apps targeting Android Q. -->
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
</manifest>