Search code examples
androidcalendarandroid-permissionsandroid-6.0-marshmallowandroid-syncadapter

Android M app update and Permission for a Sync Adapter


I have an app using a AbstractThreadedSyncAdapter for syncing a calendar. We are working on a build for android M. I have the calendar permission requests working in all cases except where the user already has the syncing setup and then upgrades our app from a non android M build to the new M build.

A] I can check the permission the first time the user opens the app after he upgraded it, but he may not open the app for a few weeks, during which his calendar will not sync.

B] I am heading toward the following option: The background sync service would start an activity that displays an explanation why we now need calendar permission because of the upgrade to M.

My question is: Is B] the best option ?


Solution

  • Is B] the best option ?

    IMHO, no. Raise a Notification, alerting the user of the need to grant the permission. When the user taps on the Notification, then go through requestPermissions() and ask the user for the permissions that you need. If the user ignores the Notification, remind them periodically (e.g., once a day) with a fresh Notification.

    This achieves your objective of alerting the user to the problem without interfering with whatever they happen to be doing at the time you decide that you need this permission.