2011-04-21 35 views
1

我试图重新启动(通过代码)手机在某些时候。为了做到这一点我做到这一点:重启Android手机 - 许可拒绝


Intent i = new Intent(android.content.Intent.ACTION_REBOOT); 
    i.putExtra("nowait", 1); 
    i.putExtra("interval", 1); 
    i.putExtra("window", 0); 
    this.sendBroadcast(i); 

的问题是,即使我有在清单这一行:

uses-permission android:name="android.permission.REBOOT"(带分隔符)。

当试图执行它,它给了我一个错误:


Permission Denial: not allowed to send broadcast android.intent.action.REBOOT from pid= uid= gids= 

我读了你应该创建一个.apk文件,并签署SignApk,但我创建的关键/ openssl证书并用这些签名,这也没有运行,我继续得到完全相同的错误。

你有关于如何解决这一点,并能够重新启动手机任何线索?我确实需要这样做。

回答

0

http://www.krvarma.com/posts/android/security-permissions-in-android/

Permissions are granted to the application by package installer while installing. But not all the permissions will be granted to the system. There are some system permission which will not be granted to the user applications, but only to the system applications. Following are some of the permissions that may NOT be granted to the user application.

To get these permissions, the application must be signed with the key which used to sign the platform. This may be different for manufacturers. So it practically not possible to get these permissions granted to a user application.

3
public static final String ACTION_REBOOT 

Since: API Level 1 
Broadcast Action: Have the device reboot. **This is only for use by system code.** 
**This is a protected intent that can only be sent by the system.** 

Constant Value: "android.intent.action.REBOOT" 

http://developer.android.com/reference/android/content/Intent.html#ACTION_REBOOT

所以,除非你去关带,并依靠其超级用户,你将无法强制重新启动。

1

对于通过代码重新启动Android设备u需要它仅到系统应用,或它们使用相同的密钥作为系统应用程序签署的申请书授予“android.intent.action.REBOOT”权限。除此之外,还必须在Android Manifest android:sharedUserId =“android.uid.system”中添加一个标签。以确保应用程序共享与系统应用程序相同的uid。

用于签名系统应用的关键。对于设备制造商来说是独一无二的,它不能被复制。