andriod应用程序开机自动启动
来源:互联网 发布:js将字符串转为数组 编辑:程序博客网 时间:2024/06/12 20:13
开机自动启动,实现很简单:步骤如下
1、在AndroidManifest.xml中注册receiver
- <receiver android:name=".BootReceiver"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED"/>
- </intent-filter>
- </receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
3、AutoStart.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class AutoStart extends BroadcastReceiver {
static final String ACTION = "android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION)){
Intent sayHelloIntent=new Intent(context,MainActivity.class);
sayHelloIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(sayHelloIntent);
}
}
/*if(intent.getAction().equals("android.intent.action.BOOT_COMPLETED")){
Log.d("BootReceiver", "system boot completed");
Intent intent2=new Intent(context,BeginActivity.class);
intent2.setAction("android.intent.action.MAIN");
intent2.addCategory("android.intent.category.LAUNCHER");
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent2);*/
}
注意:
AutoStart .java 要 和MainActivity.java放在一个包下!
或者在注册AutoStartr 的时候,对命名的相应改动
资源下载地址:http://download.csdn.net/detail/chixinwuxue/8253125
- andriod应用程序开机自动启动
- 开机自动启动应用程序
- C#开机自动启动应用程序
- wince开机自动启动应用程序
- wince开机自动启动应用程序 .
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- 让Symbian应用程序开机自动启动
- Linux自动开机时启动应用程序
- WinCE5.0应用程序开机自动启动
- 第16周项目3-用函数指针调用函数(吃饭、睡觉、打豆豆)
- 利用字典实现Python中简单的ORM映射
- SpringSide3中多数据源配置的问题
- android事件处理机制
- Linux编译内核详解(转)
- andriod应用程序开机自动启动
- sharepoint 2013 开启 Usage and Health Data Collection
- 归一化
- WeixinJSBridge
- Ubuntu 安装Oracle 11g R2
- 如何一个android工程作为另外一个android工程的lib
- Linux apache tomcat 集群搭建
- 的v私人哥啊任何事
- android控件开发之Radio(单选按钮)和CheckBox(多选按钮)开发