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、注意权限

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.shutdown.ft"

android:versionCode="1"

android:sharedUserId="android.uid.system"

android:versionName="1.0">

<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".Shutdown"

android:label="@string/app_name">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

<uses-sdk android:minSdkVersion="7" />

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

</manifest>

更多相关文章

  1. 初学者----Android(安卓)自定义View,进度条,第三方框架
  2. android 文件系统结构及其引导
  3. android linux 最全的基础知识总结
  4. Android反编译工具绿色版V2.1(改进版)
  5. GitHub 优秀的 Android(安卓)开源项目(值得研究)
  6. android: 制作system.img(yaffs2) 镜像
  7. android修改Zxing源码,避免出现错误信息
  8. Android(安卓)源码中编译Android(安卓)studio工程
  9. Android剪切板(ClipboardManager)复制文本

随机推荐

  1. react-native 使用android DownloadManag
  2. android studio的使用说明
  3. Android开发规范以及注意事项
  4. 为Android Things构建Android IoT应用
  5. android 拍照或选择图片的实现方式//Atle
  6. Android6的Logger日志系统
  7. Android 中的拿来主义(编译,反编译,AXMLPri
  8. Android:使用pagerslidingtabstrip做Tab
  9. android bionic移植需要注意的事项
  10. android XMPP