I'm following the SyncAdapter tutorial at https://developer.android.com/training/sync-adapters/index.html. So I've got all of the Stub classes in place, and it's all wired up. The SyncAdapter itself is the one from the tutorial, so does nothing but log a message. The following all work:-
The account is visible in settings/accounts
Disabling/enabling sync in settings causes a sync
Choosing "sync now" causes a sync
Calling mResolver.requestSync(mAccount, AUTHORITY, settingsBundle); causes a sync
However, that's as far as it goes. I'm expecting network events, (eg WiFi becoming available) to trigger a sync, but it isn't.
Have I misunderstood what mResolver.setSyncAutomatically(mAccount,AUTHORITY,true); does, or is there something else preventing automatic syncing?
Related
Sometimes when a phone connects to Android Studio, it will print logs between the time it was last connected to Android Studio and the present. This is cool, but I can not replicate it. Some times it happens, sometimes it does not.
I have a guess that this is a feature of USB and wireless debugging, and that logs are put in a temporary file so they can be sent to logcat when reconnected. If so, how do I keep the USB debugging from turning off when testing my device in the field during the day, so I can get the logs that were printed during the day? If not, what is happening?
The logs are nothing to do with Android Studio (or logcat in general) - it's just system logging happening on the device, and that happens whether it's connected to a log-reader or not.
At a guess, what's happening is your app's process is being closed, so the next time it runs it gets a different PID (process ID). When you connect it to the computer, your dropdown shows the currently running app process, and filters by its PID, so you don't see the old stuff.
You've probably seen this while debugging - if you re-run your app, the log "clears" and gives you a fresh one for the new run of the app. The old log messages are still there (as well as a hell of a lot of other logs for all the stuff going on on the device - it is noisy), it's just that you can't see them.
The simple thing to try is going to the filter dropdown on the right of the logcat window, and choose No filtering. Then in the filter query thing next to it (with the 🔎) type the name of your app, maybe its package. It's not perfect but it should show you all of the logs it has from your app, along with a bunch of system stuff that's also referring to it. You could get clever with PIDs or setting up a custom filter in the dropdown to get better results.
You might also be interested in the guide (with some filtering tips) and the commandline version if that's more useful to you
When I start any device from the AVD Manager it just loops this error message infinitely:
E/AudioFlinger: read failed: framesRead=-1
It even does that when I create a new device. Doesn't matter if "Use Host GPU" is enabled or not.
When I start my application it would usually start up right after the emulated device started up. Since this error message appears it does not start my application automatically (the app can still be started manually though).
Anyone else had any experience with that and maybe a possible solution?
EDIT 1: It stops looping the error message as soon as i hit the app button. Seems to just occur on the home screen.
Open Google Settings app > Search & Now > Voice
Here you need to turn off "OK Google" Detection. It may be grayed out and disabled with mark "Retrieving settings...". To make it enabled, just change the language to any other one in the field above it. If selected language is unsupported for "OK Google" detection, the switch inside this menu will be also grayed, it fixes the problem as well.
I have the same problem, and if I don't stop it, Logcat will "say" "Too much output!" and if I still don't stop it, I get prompts to send an error report to Google, even freezes.
I finally learned to put a strange set of characters that can't possibly be displayed by an error message (I use "~~~~~") and put the same string as the first argument of my Log statements and all I see are my own messages. Of course this means I don't see errors, especially Exceptions, so I just put Excep after the string "~~~~~" and delete them one by one (otherwise, here comes the deluge again).
make sure you have audio permission in your manifest:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
I am using calendar provider to create and delete events.
The problem occurs in some devices when I try to remove events. Android OS shows a notification saying:
"Too many Calendar deletes"
with options to proceed.
I couldn't find an answer to fix it in Android, only read about calendar API limitation. But it's unacceptable to offer a feature to clientes with this notification.
I am running the following line to remove an event:
context.getContentResolver().delete(eventUri, null, null);
Thanks!
I'm afraid, there is no "correct" way to bypass this message and you also shouldn't even try. This is shown because the sync adapter has set the tooManyDeletions flag in the SyncResult object to true after trying to sync.
The sync manager will always show this message if the flag is set to true.
The number of allowed deletions is defined by the respective sync adapter or by the API it's syncing to. So if you see the message depends on the account type and maybe even on the version of the sync adapter.
This is a mechanism to protect the user's data from being deleted due to a mistake (either by himself or by broken software).
You could try to trick the SyncManager and the sync adapter by triggering a sync on the respective account with the SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS flag being set by your code, but you really shouldn't do that. Actually I would consider this a bug in Android if it works.
You should communicate this to the user and sell it as a feature.
Update:
To trigger a sync with SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS call this:
Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
extras.putBoolean(ContentResolver.SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS, true);
ContentResolver.requestSync(accountOfCalendar, CalendarContract.Authority, extras);
accountOfCalendar is the account of the calendar that you deleted the events from.
Use it with care.
I am writing an app which uses the SyncAdapter framework. By default, the user has to activate the sync in the android account settings.
However, I was told that by calling
ContentResolver.setIsSyncable (mAccount, AUTHORITY,1);
I can activate the syncing without any user interaction.
Sadly, this doesn't seem to work. Even after a complete reinstall of the app, the sync adapter service is not running and the account settings look like this:(See screenshot below.)
What could I possibly be missing? Is it a problem maybe that I am calling ContentResolver.setIsSyncable (mAccount, AUTHORITY,1); from the content provider as opposed to the activity?
We are currently trying to solve this issue which is occurring only on some devices among our users.
Our application a reporting system which lets the user to collect information and take pictures which they can then export to our server. Once exported successfully they can download various reports from their on-line account.
The symptoms that we are getting on some of the android devices (running with froyo) are as following
Our app becomes sluggish and slow (all the lists and buttons respond with a lag)
If user takes a photograph it takes 10-15 seconds to for that photo to get saved
All the changes that user is making (adding new items to their report) does not get saved to disk and in the event of app (or even the whole device) crashing user looses all the data that he/she has so far collected.
On close inspection of these problematic tablets (all of these are Samsung Galaxy 7" tablets), we have found that there is a constant call to LicensingServer going in the background which is keeping everything busy. Our app does not use license and this background request for licence check has nothing to do with our app. Still the effect is very negative on our app. As you can notice from following section of logcat, the device is making 8-9 calls to the licensing server every seconds.
02-03 14:38:47.976 LicenseValidator(31668)Error contacting licensing server.
02-03 14:38:47.823 LicenseValidator(31668)Error contacting licensing server.
02-03 14:38:47.710 LicenseValidator(31668)Error contacting licensing server.
02-03 14:38:47.577 LicenseValidator(31668)Error contacting licensing server.
02-03 14:38:47.347 LicenseValidator(31668)Error contacting licensing server.
02-03 14:38:47.218 LicenseValidator(31668)Error contacting licensing server.
02-03 14:38:47.108 LicenseValidator(31668)Error contacting licensing server.
This constant hit has adverse effect on everything.
My question is, why does it try to contact licensing server so many times and if there is a way to stop it from doing so. As a part of our set-up we always turn off the "Background data" and "Auto sync" (which is under Settings - > Accounts and sync). The reason we do this because we don't want our users to access Android Market (its a part of management rulebook given to us as a part of this contract).
Even if we turn on the Background data the master Gmail account is the one that is set by us and the user does not have password for it. In this case sometimes the device goes into non-sync state (which is shown as an orange triangle icon at the notification bar at top). In this case also the device goes into this madness calling the licensing server 8-9 times every second.
Is there a way to make the device stop contacting the licensing server completely. We have spend last one week searching every possible corner of on-line forums and Android documentation. We have not yet come across anyone out there facing this problem. Any help or hint towards a solution will be hugely appreciated.
Usman Chamad
I was receiving a message that read "Market Licensing Error ... In order to validate your license, you need an Internet connection and to be logged into your Google Account." After clicking on the "validate license" button, it would come back with a message "License Validation Failed".
Many people, like me, turn off "Background Sync" & "Auto Sync" (Settings/Accounts & Sync/Background Data) on their Droids/Evo because it uses a great deal of battery power. I was going crazy trying to figure out how to get that annoying message to stop appearing every 30 seconds.
So, I logged into my Google G-mail, went into Settings/Accounts & Sync/Background Sync. Checked the box next to "Background Sync" and clicked the button to validate license. It worked, and even came back with a message "License Validation Successful" after about 5 minutes of me not knowing if it would even work. I then, of course, un-checked the box next to "Background Sync" and also un-checked the box next to “Auto Sync”.
I have to look at these settings about once a week because it seems to magically check itself once in a while, probably after an up-date, I don't know. But, when I notice my battery life is getting used too quickly, I check to make sure the box next to "Background Sync" and "Auto Sync" are un-checked.