Problem syncing using SyncAdapter in Marshmallow and above

The basic logic . Maintaining a published article in a local database. Synchronize the article when the device accesses the network.

Used classes :

  • Model class for the article.
  • AccountManager to process the account.
  • SyncService class registered in AndoidManifest with android metadata: name = "android.content.SyncAdapter" Android: resource = "@ XML / SyncAdapter"
  • The SyncAdapter class extends AbstractThreadedSyncAdapter, which is used by SyncSevice.
  • ArticleProvider extends the ContentProvider class, which manages article data in ContentProvider.
  • syncadapter.xml that contain a valid ContentAuthority.

The app works as expected before the Lollipop version . (those.). Data on data delivery from the content provider and publication to the server is provided when there is a network connection.

The problem arises from the Marshmallow version , RequestSync () does not start onPerformSync (). So Syncing is not happening. Provide an offer in this case.

+5
source share
1 answer

The problem arises from the Marshmallow version, RequestSync () does not start onPerformSync (). So the synchronization does not occur. Provide an offer in this case.

@Sackurise Android 6.0 M implemented Doze and App Standby modes. It was supposed to be a real cool thing to manage energy conservation, but it wasn’t. Many developers have the same problem as you. Their background services / application process is not working properly, and the problem is this new feature in Android M.

Although Google says adding your application to a special whitelist can solve the problem (only when necessary, or your application can be banned from the Google Play Store, please see https://developer.android.com/training/monitoring -device-state / doze-standby.html ), Google Code has a message that relates to the whole problem, and even a Google employee admitted that this whitelist does not help applications that rely on background work (network access, data retrieval sensors ....)

I will leave a link to this post here https://code.google.com/archive/p/android-developer-preview/issues/2225

This only happens in Android M, since I am testing my application on Android Nougat and it works as it is supposed to work (Nougat has Doze and App Standby features, but they have been improved).

I urge you to continue to search for a solution to this problem, and if you have success on this, please share!

+3
source

Source: https://habr.com/ru/post/1274831/


All Articles