Android: enable / disable auto sync and background data

I want to develop an application that disables background data (a new feature in Android 1.5) and auto-sync, and then activates the GPRS / EDGE connection and vice versa.

I figured out how to enable / disable GPRS / EDGE by changing APN settings. (a strange solution. However, Android developers could not think that the user could disable GPRS / EDGE). But I could not find a way to enable / disable the auto sync and background data.

I researched the Android code, and as I understood it, the synchronization operation is the intention. So, I wanted to contact putExtra and intend to enable / disable. But; I could not find the correct keyword. Or maybe I'm completely wrong. So I need some advice.

If you could tell me how I can do this or where I should look, I would be very happy. Thanks.

+3
source share
4 answers

In my dreams, HTC has a checkbox to turn off automatic syncing. I can find the arborescence menu if you want you to find that the callback function is in the Android source code. But I'm sure auto-sync cannot be completely disabled. Eliminating automatic synchronization will prevent time synchronization from synchronizing, but this will happen every time you launch the application with synchronization capabilities, if a network connection is available.

Good luck anyway.

EDIT:

There are two ways to get the information you need.

-, ndroid-sources/packages/apps/Settings/src/com/android/settings/Utils.java, , , , .

- , Google (http://smartphoneandroid.com/2008/12/28/toggle-setting-perfect-app-for-android-phone.html), , , . Android. , Android, yopmail.

+4

- , . , - ​​ . , , .

+2

AutoSynch

ContentResolver.setMasterSyncAutomatically(false);

ContentResolver.setMasterSyncAutomatically(true);

:

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

setMasterSyncAutomatically() ContentResolver . : general-sync-settings-auto-sync-checkbox-programtically

+1

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


All Articles