How to edit accounts & sync settings for a specific account - android

Under the 'Accounts & Sync' settings graphical OS menu, there are listings of user-configured Google accounts.
Please could someone point me in the right direction to programmatically change the sync settings associated with one of these accounts?
Thanks

Those settings use the new AccountManager APIs. Here's some sample code that shows how to add a new account. I'd assume that you'd want to get the credentials of one of the existing accounts and simply modify the data.
Unfortunately, I haven't had a chance to try out those APIs yet.

Maybe ContentResolver#setIsSyncable() can do what you want.
Perhaps would be better to fire the android.provider.Settings.ACCOUNT_SYNC_SETTINGS intent with either the EXTRA_AUTHORITIES extra set to ["google.com"], or possibly put the extra named "account" as the Account object you got from AccountManager. Then your user can turn their sync on or off for themselves.

ContentResolver.setSyncAutomatically(account, authority, true/false): sets whether or not the provider is synced when it receives a network tickle.

Related

Getting statistics (analytics) about number of users with root

How can I get statistics about how many of my users have rooted phone? Does the Google/Firebase analytics produce such reports?
Update: I know how to check root permissions. The question is how can I get statistics? I can add check for root in Application onCreate() and send it to analytics. But I will get so many events as the number of starts of applications, what is not what I am looking for. Of course, I could write my own backend and send some device id and and root status there but I think I am not the first and it is not needed to write my own bicycle.
I want to be able to see something like: "In last month, 30% of active users had rooted phones."
P.s. I do not have experience with google analytics, so if it is possible to somehow specify such type of event (for example, I already have value "isRooted = false" in my application), show me an example or give a link to manual, please.
Rather than using events, I would use Firebase Analytics user properties.
Define the property "is_rooted" in Firebase console > Analytics > User properties > New
Set the property in your code (Your main activity's onCreate() sounds good) :
FirebaseAnalytics.getInstance(this).setUserProperty("is_rooted", true|false);
Then you can use this property in filters, and even create audiences, etc. in the console.
Hope this helps.
No, Firebase/Google Analytics does not contains method(s), who provided this info.
But, you can check independently, if device was rooted and send your custom report.
You can check root permissions like this

How to add extra information to PayPalPayment?

Is there a way to add extra information to PayPalPayment (for example purchase-id, shipment address and things like that) using Android SDK? I don't need to show this info to the user, I just want to get it from PayPal with purchase information later. How do I do that?
Unfortunately, custom invoice-id/payment-id, shipping address, and funding source selection are not yet available. However, expect more updates on this soon! Be sure to watch the GitHub repo for updates.

Editing custom accounts

I have created my own custom account and that is working fine to add an account and to use it in the app.
I now want to be able to edit the account information instead of removing and adding an account. I have a number of fields on my account and some can be a bit lengthy, so removing and adding is rather cumbersome.
I have created the basics for this by adding my own PreferenceScreen and connected it via the android:accountPreferences in my account-authenticator XML file as per the example here: AbstractAccountAuthenticator.
In my PreferenceScreen I define an intent to open my activity that is used to enter the user data for the account.
<PreferenceScreen
android:key="edit"
android:title="Edit Account Details"
android:summary="Change System ID, user name, password etc.">
<intent
android:action="my.app.accountmanager.UserCredentialsActivity.ACCOUNT_SETUP"
android:targetPackage="my.app.accountmanager"
android:targetClass="my.app.accountmanager.UserCredentialsActivity" />
</PreferenceScreen>
My issue is, how do I either pass along as extras in the intent or find the account information for the account I selected in the Settings/Accounts & Sync. It is possible to have multiple accounts of this custom account type, so I can't just search for any account of that type. I need the data from the selected account.
My thoughts have roughly been in these areas:
Include something in the xml to add extras. Don't see how this can be possible.
Have the target for the intent be my AccountAuthenticator class or the authenciation service, but how do I pass in that I want to edit the data? Since AbstractAccountAuthenticator has a method updateCredentials that returns a bundle with the intent to my data entry activity, that could perhaps work if I could pass in an EDIT action or something like that.
Override some method somewhere to create my own intent with the account data.
I hope this is possible to do as both a Samsung app and the Dropbox app do this from the Accounts & Sync, although neither allow multiple accounts...
I think the accountPreferences attribute in AbstractAccountAuthenticator is going to be obsolete soon. If you look at the accounts in JB, if you add multiple accounts, it is going to be displayed like this
account1#gmail.com
account2#gmail.com
Preference
Instead of
account1#gmail.com -> Preference
account2#gmail.com -> Preference
And if you take a look at the Gmail app, the preferences (notifcation ringtone) for Gmail is configured within the Gmail app itself, and can't be configured from the Accounts & Settings page.
So, you should only use the accountPreferences attributes for preferences that are common to all accounts.

Is it possible to turn on synch in Android Account

I'm working on an application that will allow a user to turn on/off synching for their exchange email account.
I am able to get the exchange account using:
Account[] accs = AccountManager.get(this).getAccountsByType("com.htc.android.mail.eas");
but the Account API doesn't seem to offer what I'm looking for. I have also found ContactsContract.Settings database table which stores synch data, but I'm not that sure where to start with that.
Any ideas?
The ContentResolver contains the API you are looking for.
Check out the "setIsSyncable" method.

How to change sync settings through Android API?

Is there a way to change the sync settings of a Gmail account programmatically with an Android app? For instance, I'd like to enable/disable syncing of a Gmail account from my app, without the user having to do anything.
I took a look at AccountManager, but that doesn't seem to be the right place to look.
You can change it through the API using ContentResolver.setSyncAutomatically(Account account, String authority, boolean sync). You need to get a handle to the account in question (usually through the AccountManager class...) and you'll need to lookup the content authority string. The latter you can get from android.Provider.xxxContract (ContactsContract for example...)
I can tell you:
Generally, sync is controlled via the BACKGROUND_DATA setting in Settings.Secure, which cannot be modified by applications
The Gmail application is not part of the SDK and so exposes no APIs

Categories

Resources