Upgrade to Pro — share decks privately, control downloads, hide ads and more …

That's your Q / 10

That's your Q / 10

The API changes in Android 10, how would it affect existing applications, and ways to adapt to those changes

Hussain Mukadam

August 24, 2019
Tweet

More Decks by Hussain Mukadam

Other Decks in Programming

Transcript

  1. Things we’ll talk about > Scoped Access Framework > Media

    Store > Location Access Restrictions > Other noticeable changes that might break your apps / or not..
  2. Storage Access Framework or Scoped Storage All apps will be

    affected in Android R / 11 / XI If uses-permission == READ_EXTERNAL_STORAGE AND / OR uses-permission == WRITE_EXTERNAL_STORAGE
  3. Introducing the Filter Android 1.0 to 9.0 - access filesystem

    with permission Android 4.4 - access parts without permission - context.getExternalFilesDir() Android 10 (Opt) - 11 - changes this behavior completely
  4. Opt out - Android 10 android:requestLegacyExternalStorage="true" To your <application> element

    in your manifest Storage behavior for when your app runs on Q / 10 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && Environment.isExternalStorageLegacy())
  5. Adapting to Scoped Storage Inbound actions - ACTION_VIEW AND ACTION_SEND

    Creating content - FileSystem AND ACTION_CREATE_DOCUMENT Sharing content - FileProvider AND MediaStore
  6. But I need a File.. Not everything can work with

    Uri Option #1 - API Supports File like System Option #2 - Ask User to Put it in App-Specific location Option #3 - Copy stream to Local File
  7. Removing support for Files file:Uri android:scheme=”file” While if you use

    https and content schemes it will still be supported in targetSdkVersion <= 29
  8. Unfortunately neither <data> nor <intent-filter> have an android:enabled option that

    we can use. Make changes to the <activity-alias> instead. Deprecations StorageVolume.createAccessIntent()
  9. Media Store > What you can do - Query the

    _ID Column - Use ContentUris.withAppendedId() to assemble a Media Store Uri from base Uri for the type of content
  10. Media Store - Permissions > Writing own content - No

    Permissions > Consuming content added to MediaStore by others - READ_EXTERNAL_STORAGE RecoverableSecurityException which has RemoteAction
  11. MediaStore > Consume Media Option #1 - Ask some other

    app to open it Option #2 - Query it yourself > Creating Media Changes behavior only on Q / 10
  12. Option #2 - Query it yourself > Get root Uri

    - MediaStore.Audio.Media.EXTERNAL_CONTENT_URI MediaStore.Image.Media.EXTERNAL_CONTENT_URI MediaStore.Video.Media.EXTERNAL_CONTENT_URI OR if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL) else MediaStore.Video.Media.EXTERNAL_CONTENT_URI
  13. Creating Media Previously - write media to file - get

    MediaStore to index it - using MediaScannerConnection Now - use insert() on ContentResolver - returns Uri ContentValues that you wish to add DISPLAY_NAME and MIME_TYPE Android Q / 10 also offers RELATIVE_PATH - controlling where the media goes on the device.
  14. Location Access Restrictions > App in foreground - goes temporarily

    in the background > App completely in the background > EXIF Metadata Redaction
  15. App in Foreground Start a Foreground Service android:foregroundServiceType="location" on its

    <service> manifest element Service will continue receiving updates
  16. App in Background New Permission - ACCESS_BACKGROUND_LOCATION The user winds

    up with three basic options in terms of granting rights to your app: • Unfettered access to location • “Only while the app is in use”, which translates to “only while the app has UI in the foreground” • No access at all
  17. EXIF Metadata Redaction > JPEG Images - Tags - Eg.

    Orientation > Geotagged - EXIF Tags > MediaStore - Acc to Documentation - Your app needs to hold the ACCESS_MEDIA_LOCATION permission (which is dangerous and needs to go through runtime permissions) - Your app needs to call MediaStore.setRequireOriginal(), supplying the Uri for which you would like the location — this method then returns a decorated Uri that can be used with openInputStream()
  18. Stuff that might break your app.. > Background Activity Starts

    are Banned - Foreground service cannot startActivity() - Pending Intent tied to a Notification can startActivity() Alternative > High importance - high priority Notification > setFullScreenIntent(pi, true) > You need to request the USE_FULL_SCREEN_INTENT permission.
  19. Stuff that might break your app.. > Non-SDK Interfaces -

    Class.forName(), getConstructor(), getField() - StrictMode > SYSTEM_ALERT_WINDOW Restrictions > Background Clipboard Access Banned, unless - They are the default input method editor, or - They are “the app that currently has focus”
  20. Stuff that might break your app.. > ContactsContract Field Deprecations

    - ContactsContract.ContactOptionsColumns.LAST_TIME_CONTACTED - ContactsContract.ContactOptionsColumns.TIMES_CONTACTED - ContactsContract.DataUsageStatColumns.LAST_TIME_USED - ContactsContract.DataUsageStatColumns.TIMES_USED
  21. Stuff that might break your app.. > android:sharedUserId Deprecated >

    DownloadManager Deprecations - addCompletedDownload() - allowScanningByMediaScanner() on DownloadManager.Request - setVisibleInDownloadsUi() on DownloadManager.Request > More Densities - 140, 180, 200, 220 - Only care if DENSITY_ constants on DisplayMetrics
  22. Stuff that might interest you.. > Preference Deprecation - (Eg

    EditTextPreference, ListPreference) > ACTION_SEND Previews - Add EXTRA_TITLE to the ACTION_SEND Intent, with some text to appear as the title of the preview - Add a ClipData to the ACTION_SEND Intent, via setClipData(), that represents the image to show as part of the preview
  23. Stuff that might interest you.. > Settings Panel - Settings.Panel.ACTION_INTERNET_CONNECTIVITY

    - Settings.Panel.ACTION_NFC - Settings.Panel.ACTION_VOLUME - Settings.Panel.ACTION_WIFI
  24. Stuff that might interest you.. > Roles / RoleManager -

    You need to have stuff in the manifest to be eligible for it - You need to have code to detect if you have the role — and if not, to ask the user to grant you the role - The user can grant or revoke roles at any point (e.g., via the Settings app) - The role helps determine what your app can do - Only a single app can have it
  25. Stuff that might interest you.. > Roles / RoleManager -

    - <intent-filter> - <category android:name="android.intent.category.DEFAULT" />, to declare your wish to be the default app for the role - A second <category> element tied to the specific role - isRoleAvailable() - isRoleHeld() - createRequestRoleIntent()
  26. There’s a lot more.. > Share Targets > Dark Mode

    > Gesture Navigation > Deep Presses > Bubbles
  27. References > Android Developers Blog - https://developer.android.com/preview/feature > Videos -

    - https://www.youtube.com/watch?v=L7zwfTwrDEs - https://www.youtube.com/watch?v=oYyf5yMVZZs - https://www.youtube.com/watch?v=OCHEjeLC_UY