android实现简单定时关机应用程序
2012-11-20 15:11:29 来源:WEB开发网核心提示:在Manifast.xml文件中添加如下权限: <uses-permission android:name="android.permission.SHUTDOWN"/> <uses-permission android:name="android.permission
在Manifast.xml文件中添加如下权限: <uses-permission android:name="android.permission.SHUTDOWN"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>"
还是贴出来吧:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>"
还是贴出来吧:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jxnu.shutdown"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.SHUTDOWN"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>"
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ShutdownActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".ServiceActivity" android:label="@string/app_name" android:enabled="true"></service>
<receiver android:name=".ShutdownBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>
</application>
建立一个 BroadcastReceiver来接收广播android.intent.action.BOOT_COMPLETED(每次开机就启动service)
package="jxnu.shutdown"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.SHUTDOWN"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>"
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ShutdownActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".ServiceActivity" android:label="@string/app_name" android:enabled="true"></service>
<receiver android:name=".ShutdownBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>
</application>
建立一个 BroadcastReceiver来接收广播android.intent.action.BOOT_COMPLETED(每次开机就启动service)
更多精彩
赞助商链接