转:android中APK开机自动运行
package com.ghstudio.BootStartDemo; import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView; public class SayHello extends Activity { @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); TextView tv = new TextView(this);
tv.setText("Hello. I started!"); setContentView(tv);
}
}
package com.ghstudio.BootStartDemo; import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; public class BootBroadcastReceiver 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,SayHello.class);
sayHelloIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(sayHelloIntent);
}
} }
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ghstudio.BootStartDemo"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".SayHello"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="3" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission> </manifest>
===========================================
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>
这样,程序就可以在开机时自动运行了
转自:http://blog.csdn.net/wh_19910525/article/details/7921685
转:android中APK开机自动运行的更多相关文章
- [转载] 在Linux中,开机自动运行普通用户的脚本程序
FROM:http://blog.csdn.net/sinboy/article/details/2466225 FROM:http://www.2cto.com/os/201006/50680.ht ...
- Android---让你的APK程序开机自动运行(转)
转自: http://blog.sina.com.cn/s/blog_72f6e45701014l6t.html 有些时候,应用需要在开机时就自动运行,例如某个自动从网上更新内容的后台service. ...
- 【转】]Android实现开机自动运行程序
有些时候,应用需要在开机时就自动运行,例如某个自动从网上更新内容的后台service.怎样实现开机自动运行的应用?在撰写本文时,联想到高焕堂先生以“Don't call me, I'll call y ...
- Android实现开机自动运行程序
有些时候,应用需要在开机时就自动运行,例如某个自动从网上更新内容的后台service.怎样实现开机自动运行的应用?在撰写本文时,联想到高焕堂先生以“Don't call me, I'll call y ...
- Android开机自动运行APP——BroadcastReceiver
前言: 有些时候,应用需要在开机时就自动运行,例如某个自动从网上更新内容的后台service.怎样实现开机自动运行的应用?在撰写本文时,联想到高焕堂先生以“Don't call me, I'll ca ...
- C#.NET Form设置/取消开机自动运行,判断程序是否已经设置成开机自动启动(转载)
#region//开机自动运行 private void CB_Auto_CheckedChanged(object sender, EventArgs e) {//CB_ ...
- C# 设置程序开机自动运行(+注册表项)
有时候我们需要让软件安装好了,开机自动运行,这时我们需要把启动项加载到注册表中,需要注意的时现在很多杀毒软件在其他软件更改注册表的时候会有提示,可能会阻止.下面代码包含增加启动项到注册表和删除启动项. ...
- C#安装程序制作让安装后的程序开机自动运行
1.创建安装项目后要在自己的解决方案是添加一个新的类库项目(ClassLibrary1),并在新类库中添加一下安装程序类(Installer1),在Installer1类中添加如下代码: string ...
- /etc/rc.local 与 /etc/init.d Linux 开机自动运行程序
1. /etc/rc.local 这是使用者自订开机启动程序,把需要开机自动运行的程序写在这个脚本里 --------引用---------------------- 在完成 run level 3 ...
随机推荐
- Cocos2d-x MultipleTouch & CCControllButton's confusion
在cocos2dx的程序设计中有时候会遇到需要多点触摸的功能,下面先介绍一下在cocos2dx中多点触摸的一般规则,然后介绍我遇到的一个有关多点触摸的情景的解决方案. (一)使用多点触摸规则: 关于多 ...
- 记RedisDesktopManager的一次崩溃
redis3.2的配置文件中有bind监听地址 bind 192.168.42.131默认bind的填写的127.0.0.1这样配置是只允许本地访问,如果想远程访问就改为本机网卡绑定的ip地址.我这边 ...
- excel多个文件合并
多个excel文件合并成一个需要用ms office wps是不行的 1.将所有文件放在一个文件夹里 2.在文件夹里新建一个空的excel打开 右键sheet点击查看代码->输入下面代码-> ...
- 更改 Tomcat 日志路径
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- IOS Label 自动换行 IOS6和IOS7
IOS 6和ios7 不一样,所以,我们分开来: IOS6: //计算实际frame大小,并将label的frame变成实际大小 CGSize size01 = [ssizeWithFont: ...
- 【42】了解typename的双重意义
1.在template声明中,class与typename是等价的,但是使用typename更好. 2.在template实现中,模版形参是从属名称,嵌套在模版形参中的类型是嵌套从属名称,不依赖任何t ...
- android95 缩放加载大图片
MainActivity: package com.itheima.loadimage; import android.os.Bundle; import android.app.Activity; ...
- MySQL主主复制+LVS+Keepalived实现MySQL高可用性
http://bestvivi.com/2015/09/09/MySQL%E4%B8%BB%E4%B8%BB%E5%A4%8D%E5%88%B6+LVS+Keepalived%E5%AE%9E%E7% ...
- careercup-递归和动态规划 9.5
9.5 编写一个方法,确定某字符串的所有排列组合. 类似leetcode:Permutations 解法: 跟许多递归问题一样,简单构造法非常管用.假设有个字符串S,以字符序列a1a2a...an表示 ...
- [Form Builder]Oracle Form系统变量中文版总结大全
转:http://yedward.net/?id=57 Form中的系统变量,它存在于一个Form的整个运行时期的会话之中,变量包含了有关Form相关属性的字节信息.有些变量标明了当前状态,还有些变量 ...