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 源码中编译Android studio工程
  2. android修改Zxing源码,避免出现错误信息
  3. android多媒体播放源码解析
  4. Cordova 3.x 源码分析(2) -- cordova.js概要
  5. Android gallery实现图片的左右循环旋转源码分享
  6. eclipse 中绑定 android源码
  7. Android事件分发机制原理及源码分析
  8. android edittext 边框 源码实现

随机推荐

  1. android 下载图片保存在sdcard并显示可拖
  2. [Android]android.os 源代码中的Looper,H
  3. Android(安卓)-- 与WEB交互在同一个会话S
  4. Android java.lang.RuntimeException: ta
  5. Intent打开各种类型的文件
  6. Android Retrofit2 设置请求头Header
  7. Android 中 Base64的操作应用
  8. Android生成PDF文件
  9. Android中的用户词库——UserDictionry
  10. android保存Bitmap图片到指定文件夹示例