Android开机自启
来源:互联网 发布:北京谷歌seo 编辑:程序博客网 时间:2024/05/22 01:15
public class BroadCast extends BroadcastReceiver {
private static final String Action="android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Action))
{
// Intent MyScene=new Intent(context, com.slq.myapp.MyScene.class);
// MyScene.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent MyScene=context.getPackageManager().getLaunchIntentForPackage("com.slq.myapp");
context.startActivity(MyScene);
}
}
private static final String Action="android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Action))
{
// Intent MyScene=new Intent(context, com.slq.myapp.MyScene.class);
// MyScene.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent MyScene=context.getPackageManager().getLaunchIntentForPackage("com.slq.myapp");
context.startActivity(MyScene);
}
}
}
一定要把BroadCast类建在com.Slq.xxx下边,不能建在Java目录下,否则的话会开机自启的时候出错。
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.slq.myapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MyScene">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".BroadCast">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
package="com.slq.myapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MyScene">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".BroadCast">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
</manifest>
阅读全文
0 0
- Android开机自启
- Android 开机自启
- Android 开机自启
- android开机自启
- Android开机自启
- android 开机自动启动 | 开机自启
- Android 开机自启服务
- android程序开机自启
- Android应用开机自启
- Android实现开机自启
- Android应用开机自启
- android实现开机自启
- Android开机自启APK应用
- android 开机自启(holle word)
- Android APP开机自启,Xposed解决方案
- Android开机自启动
- Android开机自启动。
- 【Android】开机自启动
- 【数组处理】从数组提取相同元素并归类
- 一些图片
- android xUtils 2.6.14 jar 下载 使用 和混淆
- socket的基本操作
- vs c++使用lua
- Android开机自启
- 学习他人消灭星星代码的收获
- 1TensorFlow实现自编码器-1.4 TensorFlow实现降噪自动编码器--运行会话,训练模型
- Qt类型转换
- stl map键都是唯一的
- Springboot 上传文件至阿里云OSS
- springcloud服务调用其它服务接口实例及ribbon均衡负载
- Tomcat的账号与密码在哪?
- Linux进程的管理与调度