经过验证过的接收系统广播
来源:互联网 发布:linux如何安装tgz 编辑:程序博客网 时间:2024/05/22 06:32
1.安装应用后,首先要启动一次。
2.如果签名后,不可以用eclipse安装apk文件,手动安装好后,也要启动一次。
3.添加以下:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
4.添加以下:
<receiver android:name=".BootBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
5.代码部分:
public class BootBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
//接收广播:系统启动完成后运行程序
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
{
Intent ootStartIntent = new Intent(context, Login_Activity.class);
ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(ootStartIntent);
}
//接收广播:安装更新后,自动启动自己。
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED) || intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED))
{
Intent ootStartIntent = new Intent(context, Login_Activity.class);
ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(ootStartIntent);
}
}
}
2.如果签名后,不可以用eclipse安装apk文件,手动安装好后,也要启动一次。
3.添加以下:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
4.添加以下:
<receiver android:name=".BootBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
5.代码部分:
public class BootBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
//接收广播:系统启动完成后运行程序
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
{
Intent ootStartIntent = new Intent(context, Login_Activity.class);
ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(ootStartIntent);
}
//接收广播:安装更新后,自动启动自己。
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED) || intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED))
{
Intent ootStartIntent = new Intent(context, Login_Activity.class);
ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(ootStartIntent);
}
}
}
0 0
- 经过验证过的接收系统广播
- 学习wxpython-空的对话框-经过试验验证过
- Android接收不到系统广播的原因
- android接收adb发送的系统广播及自定义广播
- android-接收系统广播
- 接收系统广播
- 接收系统广播
- android接收系统广播
- BroadcastReceiver 接收系统短信广播
- 动/静态接收系统广播
- 广播数据包的接收
- 接收短信的广播
- android亮屏、黑屏、解锁事件的系统广播接收
- Android4.0系统接收不到广播的问题解析
- Android4.0系统接收不到广播的问题解析
- Android4.0系统接收不到广播的问题解析
- Android4.0系统接收不到广播的问题解析
- Android4.0系统接收不到广播的问题解析
- 简单的欢迎界面,延时播放
- fopen与读写的标识r,r+,rb+,rt+,w+.....
- Tomcat修改端口号
- poj 1743
- nginx+tomcat集群负载均衡下tomcat故障后的的会话转移
- 经过验证过的接收系统广播
- Struts(22)标签库详解
- 百度牵手大悦城 相爱相杀的零售与互联网需要新玩法
- MongoDB跳出循环的两种方式
- 安全框架shiro
- 为什么匿名内部类参数必须为final类型
- 简单的邮件发送
- 在textView中输入时避免键盘的遮挡
- 使用continue语句