Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android OS 2.2 Permissions: I have absolutely no idea why this simple piece of code doesn't work. What am I doing wrong?

I'm just playing around with some code. I create an Activity and simply do something like this:

long lo = currentTimeMillis();
System.out.println(lo);

lo *= 3;
System.out.println(lo);

SystemClock.setCurrentTimeMillis(lo);
System.out.println( currentTimeMillis() );

Yes, in my AndroidManifest.xml, I've added:

<uses-permission android:name="android.permission.SET_TIME"></uses-permission>
<uses-permission android:name="android.permission.SET_TIME_ZONE"></uses-permission>

Nothing changes. The SystemClock is never reset...it just keeps on ticking. The error that I'm getting just says that the permission "SET_TIME" was not granted to the program. Protection level 3.

The permissions are there...and in the API for 2.2 it says that this feature is supported now. I have no idea what I'm doing wrong.

If android.content.Intent; comes into play, please explain. I don't really understand what the idea behind intents!

Thanks for any help!

like image 403
K-RAN Avatar asked May 27 '10 05:05

K-RAN


2 Answers

There is a SET_TIME_ZONE permission but there's no SET_TIME permission. Applications cannot programmatically change the system clock.

Update

SET_TIME is available since 2.2, but can only be granted to the system process or apps signed with the system signature.

like image 86
Romain Guy Avatar answered Oct 31 '22 19:10

Romain Guy


using AlarmManager with SET_TIME permission to set system time seems to work :)

like image 24
user718146 Avatar answered Oct 31 '22 17:10

user718146