Android OS 2.2 权限:我完全不知道为什么这段简单的代码不起作用.我究竟做错了什么? [英] 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() );
是的,在我的 AndroidManifest.xml 中,我添加了:
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>
没有任何变化.SystemClock 永远不会重置......它只是不断滴答作响.我得到的错误只是说该程序未授予SET_TIME"权限.保护等级3.
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.
权限就在那里……在 2.2 的 API 中,它说现在支持此功能.我不知道我做错了什么.
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.
如果android.content.Intent;发挥作用,请解释.我真的不明白意图背后的想法!
If android.content.Intent; comes into play, please explain. I don't really understand what the idea behind intents!
感谢您的帮助!
推荐答案
有 SET_TIME_ZONE 权限但没有 SET_TIME 权限.应用程序无法以编程方式更改系统时钟.
There is a SET_TIME_ZONE permission but there's no SET_TIME permission. Applications cannot programmatically change the system clock.
更新
SET_TIME 从 2.2 开始可用,但只能授予系统进程或使用系统签名的应用程序.
SET_TIME is available since 2.2, but can only be granted to the system process or apps signed with the system signature.
这篇关于Android OS 2.2 权限:我完全不知道为什么这段简单的代码不起作用.我究竟做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!