3

I want to develop an application that disables the Background Data (new feature in Android 1.5) and Auto Sync and then enables GPRS/EDGE connection and vice versa.

I figured out how to enable/disable GPRS/EDGE by changing the APN settings. (weird solution. However; Android developers couldn't think a user may want to disable GPRS/EDGE) But, I couldn't find a way to enable/disable Auto Sync and Background data.

I investigated the Android code and as I understood, the Sync operation is an intent. So, I wanted to reach with putExtra to the intent and trigger the enabling/disabling. But; I couldn't find the correct keyword. Or maybe I was totally wrong.

What is the right way to solve this?

4 Answers 4

4

In my HTC dreams, there is a checkbox to disable the auto sync. I can look for the menu arborescence if you wish so you can find what the callback function is in the Android source code. But I am pretty sure auto sync cannot be completely disabled. Unchecking auto sync will prevent sync from being performed on a timed basis, but it will occur everytime you run an app with sync capabilities if any network data connection is available.

Good luck anyway.

EDIT :

There are two ways to get the info you desire.

First, I think you can use the code in android-sources/packages/apps/Settings/src/com/android/settings/Utils.java to create an activity that will enlist all the keys of the intent then find the one you want.

The other way is to write a nice mail to the guy who made the Toggle Setting app (http://smartphoneandroid.com/2008/12/28/toggle-setting-perfect-app-for-android-phone.html) since he obviously found a solution to your problem. His email address is written in the app sheet on the android market. I won't write it here, but if you do not have access to real android phone, I can mail it to you on your mail address.

1
  • If you can find the callback function, I will be very happy. I dig for this information. However; I couldn't find anything. On the other hand, I know that I can not prevent the third party applications to use GPRS/EDGE. But, my main aim is to disable the sync with Google server only. Because; As I observed if auto sync is on, Google sync uses most of my data plan.
    – Ömer
    May 11, 2009 at 21:42
2

Background data is a secure setting, so cannot be changed by user applications. But bear in mind, it's just a setting - it's not enforced. Apps are meant to read it and respect it but I bet some don't.

1
  • If I can find out to disable auto sync only, Background Data may not be a problem.
    – Ömer
    May 11, 2009 at 21:44
2

To Disable the AutoSynch

ContentResolver.setMasterSyncAutomatically(false);

To Enable the AutoSynch

ContentResolver.setMasterSyncAutomatically(true);

Permission you require is

<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
1

setMasterSyncAutomatically() on ContentResolver should do it. Check: general-sync-settings-auto-sync-checkbox-programtically

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.