I m using Google cloud message to send push message to device, but it have a large delay to send (if i manually click in sync google account, the message come on time). I want when i open my app (onResume activity) do "force sync" of google account.
i m trying this way:
Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_FORCE, true);
Account[] accounts = AccountManager.get(context).getAccounts();
for (Account account : accounts) {
SyncAdapterType[] types = ContentResolver.getSyncAdapterTypes();
for (SyncAdapterType type : types) {
if (account.type.equals(type.accountType)) {
boolean isSyncable = ContentResolver.getIsSyncable(account, type.authority) > 0;
if (isSyncable) {
ContentResolver.requestSync(account, type.authority, extras);
}
}
}
}
but it ill try sync all account in all ways, AND it dont work my message don't come like when i click in the menu button of sync.
how i can force (in the better way) my app to check if it have some message in google .cloud?