zoukankan      html  css  js  c++  java
  • android代码实现关机


     

                   

    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> 

  • 相关阅读:
    java的概述 常量 变量
    css 基础2
    css 盒子模型1
    css 基础1
    HTML 基础 3
    HTML基础2
    servletContext百科
    hibernate 一对多双向关联 详解
    hibernate generator class="" id详解
    Hibernate缓存原理与策略
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3142970.html
Copyright © 2011-2022 走看看