[android-developers] accessing and changing Sync setting for android 1.5, 1.6 and more

52 views
Skip to first unread message

zehunter

unread,
Apr 16, 2010, 11:53:27 AM4/16/10
to Android Developers
hi,

i'm not able to find any example or documentation or tutorial about
how to enable or disable sync (background data and auto sync)
programmaticaly, even if i can found many widget that can do that
without root access or such.

is it something secret? :-)
can any one may be good enough to help me and explain how this work
and how to implement that into my code?

i found some trick with URI and content://sync/setting but it seems to
be not possible with android 1.6 at least :-( any idea why? and what
replaced this?

thanks a thousand time for all people that will answer to me.
best regards,

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-develop...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

cpphool

unread,
Apr 20, 2010, 10:25:26 AM4/20/10
to Android Developers
[android 2.x]

as far as i know, Android 2.x introduces completely new sync mechanism
(allowing use to use multi accounts). In order to check whether global
auto-sync is on, you can use:

ContentResolver.getMasterSyncAutomatically();

and to switch it on:

ContentResolver.setMasterSyncAutomatically(true);

[android 1.x]

Did you find something about 1.6? and are you able to change auto-sync
settings in 1.5?

I tried with this snippet:

final Uri CONTENT_URI = Uri.parse("content://sync/settings");
ContentValues values = new ContentValues();
values.put("name", "sync_provider_contacts");
values.put("value", true);
getContentResolver().insert(CONTENT_URI, values);

The value changes to "1" instead of "true" and it doesn't affect sync
settings.

remy berrebi

unread,
Apr 21, 2010, 9:12:56 AM4/21/10
to android-d...@googlegroups.com
good news about android 2.x but actually, i want to make my application available for all major android version, like 1.6 and if possible 1.5

i'm still searching information.
actually i'm trying to understand reflect mechanism, to see if i can call HIDE method and class and act on sync setting.
but for now nothing work :-(

cpphool

unread,
Apr 23, 2010, 5:38:45 AM4/23/10
to Android Developers
I have added one modification and snippet works on htc magic (1.5)

final Uri CONTENT_URI = Uri.parse("content://sync/settings");
ContentValues values = new ContentValues();
values.put("name", "sync_provider_contacts");
values.put("value", "true"); // <-- here - string "true" instead of
boolean
getContentResolver().insert(CONTENT_URI, values);
> > > android-develop...@googlegroups.com<android-developers%2Bunsu...@googlegroups.com>
> > > For more options, visit this group athttp://
> > groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-d...@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-develop...@googlegroups.com<android-developers%2Bunsu...@googlegroups.com>

remy berrebi

unread,
Apr 26, 2010, 3:13:10 AM4/26/10
to android-d...@googlegroups.com
i tryed your code, but it doesn't work on 1.6 :-(

E/AndroidRuntime(  429): java.lang.IllegalArgumentException: Unknown URL content://sync/settings
E/AndroidRuntime(  429):        at android.content.ContentResolver.insert(ContentResolver.java:476)

cpphool

unread,
Apr 29, 2010, 8:58:04 AM4/29/10
to Android Developers
yes, i know it doesn't work on 1.6. there is a different content
provider there or we do not have access to "content://sync/settings".
i have looked through android source code and in 1.6 file "Sync.java"
disappears (it was available in 1.5).
> > <android-developers%2Bunsu...@googlegroups.com<android-developers%252Buns...@googlegroups.com>
>
> > > > > For more options, visit this group athttp://
> > > > groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to
> > android-d...@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-develop...@googlegroups.com<android-developers%2Bunsu...@googlegroups.com>
> > <android-developers%2Bunsu...@googlegroups.com<android-developers%252Buns...@googlegroups.com>

remy berrebi

unread,
May 1, 2010, 8:06:17 AM5/1/10
to android-d...@googlegroups.com
it's very sad.
i still not understand the fact that android is so "close" about system setting. if we can not interact with system by ourself, the possibility to make very interesting apk is very low :-(

let's all make RSS reader and clock widget and nothing more :-(

i think i will make my application for Root device only, as i read on root you have no restriction anymore.

but if google want to be so "open mind" they really need to improve access and permission on android (even old version like 1.6), and not remove them one after another :-(

thanks any way for all.

this problem end to a wall once again...

Mark Murphy

unread,
May 1, 2010, 8:27:31 AM5/1/10
to android-d...@googlegroups.com
remy berrebi wrote:
> it's very sad.
> i still not understand the fact that android is so "close" about system
> setting. if we can not interact with system by ourself, the possibility
> to make very interesting apk is very low :-(
>
> let's all make RSS reader and clock widget and nothing more :-(

There are "RSS reader and clock widget" applications on the market for
Android, but it is a very low percentage. Other developers seem to be
able to think of applications, beyond those, that can be written.

> i think i will make my application for Root device only, as i read on
> root you have no restriction anymore.

No, the "restriction" will still be there. However, you can write your
own firmware to change whatever you want.

> but if google want to be so "open mind" they really need to improve
> access and permission on android (even old version like 1.6), and not
> remove them one after another :-(

I do not recall "content://sync/settings" ever being part of the SDK.
Would you care to demonstrate that this *was* part of the SDK and
therefore something developers should be using?

If developers were not supposed to be using it in the first place,
please do not complain about it being "removed".

http://www.androidguys.com/2009/12/14/code-pollution-reaching-past-the-sdk/

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

zehunter

unread,
May 3, 2010, 11:39:30 AM5/3/10
to Android Developers


On 1 mai, 14:27, Mark Murphy <mmur...@commonsware.com> wrote:
> remy berrebi wrote:
> > it's very sad.
> > i still not understand the fact that android is so "close" about system
> > setting. if we can not interact with system by ourself, the possibility
> > to make very interesting apk is very low :-(
>
> > let's all make RSS reader and clock widget and nothing more :-(
>
> There are "RSS reader and clock widget" applications on the market for
> Android, but it is a very low percentage. Other developers seem to be
> able to think of applications, beyond those, that can be written.
>

sorry, i was a little upset and furious about not having the
possibility to make what i want to do :-(

i know many interesting apps are available, but when you touch on some
part of the system, like sync setting you can't do nothing :-(

the permission signatureOrSystem should also let user able to sign
their apps with android root certificate for example, or something, to
let dev guy able to do think about setting... and once again,
disclaimer are there to warm user about what application try to do...

> > i think i will make my application for Root device only, as i read on
> > root you have no restriction anymore.
>
> No, the "restriction" will still be there. However, you can write your
> own firmware to change whatever you want.
>

really?

> > but if google want to be so "open mind" they really need to improve
> > access and permission on android (even old version like 1.6), and not
> > remove them one after another :-(
>
> I do not recall "content://sync/settings" ever being part of the SDK.
> Would you care to demonstrate that this *was* part of the SDK and
> therefore something developers should be using?
>
> If developers were not supposed to be using it in the first place,
> please do not complain about it being "removed".
>
> http://www.androidguys.com/2009/12/14/code-pollution-reaching-past-th...
>

sorry, i'm not able to show you, but i found some explanation about
accessing and changing setting available on sdk 1.1

but didn't find the page any more :-(

but my main gaol is that : even if it's not implemented, we should be
able to improve the system with dev request.

> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
Reply all
Reply to author
Forward
0 new messages