1、API没有开放,需要提升为syetem app级别!
2、android 模块编译,mm 命令
2.1、先进入顶层 source build/envsetup.sh
2.2、进入目录 mm
3、android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := Shutdown
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
4、源码
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
5、注意权限
package="com.shutdown.ft"
android:versionCode="1"
android:sharedUserId="android.uid.system"
android:versionName="1.0">
android:label="@string/app_name">