android中APK开机自动运行
16lz
2022-04-20
1.要做的就是监听系统发出的broadcast
public class FlorenceText extends BroadcastReceiver{
public void onReceive(Context context, Intent intent) {
if(Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
start(context);
}
}
}
2.在AndroidMenifest.xml里还要将receiver加上, 并写明程序的入口就是FlorenceTest
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<receiver android:name=".main.FlorenceTest"
android:exported="true"
android:process=":remote">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
</application>
这样,程序就可以在开机时自动运行了
更多相关文章
- 第十一节(Android常见控件二)
- android微信摇一摇功能
- Android(安卓)扫描SDCard上的音乐文件以及监听扫描事件
- Android(安卓)动画监听器
- Android入门:Button
- Android(安卓)监听 ListView 元素数量的变化
- Android中RadioGroup RadioButton CheckBox多选按钮实现方法以及
- Android:媒体按键消息
- Android中关于EditText不能取得值的问题解决方案