先上代码:
Intent intent = new Intent(Intent.ACTION_REBOOT);
intent.setAction(Intent.ACTION_REBOOT);
intent.putExtra("nowait", 1);
intent.putExtra("interval", 1);
intent.putExtra("window", 0);
sendBroadcast(intent);这是在调用的地方,只需发送如上的广播。
在androidmanifest.xml文件中在根标签manifest中添加权限
android:sharedUserId="android.uid.system"添加上面的权限后,要源码编译。
Android.mk文件中要添加
LOCAL_CERTIFICATE := platform重启代码位于frameworks/base/core/jni/android_os_Power.cpp
本文介绍如何在Android应用中通过发送自定义广播来实现设备的重启操作,并且详细阐述了所需添加的权限和代码实现流程。

3149

被折叠的 条评论
为什么被折叠?



