android开机自启动的后台Service的实现
来源:互联网 发布:中国税务网络大学app 编辑:程序博客网 时间:2024/06/10 01:55
1.在Manifest.xml文件中注册广播接收器,接收开机广播
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sensor.demo" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <service android:name=".SensorFunctionService"></service> <receiver android:name=".BootCompletedReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </application></manifest>
2.广播接收器接收到开机广播后启动Service
public class BootCompletedReceiver extends BroadcastReceiver{@Overridepublic void onReceive(Context context, Intent intent) {// TODO Auto-generated method stub Intent mIntent = new Intent(context, SensorFunctionService.class); context.startService(mIntent);}}
3.在Service里面做要做的事情
public class SensorFunctionService extends Service { @Overridepublic void onCreate() {super.onCreate();} @Overridepublic IBinder onBind(Intent arg0) {return null;}}
这个工程没有Activity,所有安装上以后也看不见。
要做的事情需要在重启机器后方能执行,因为Service的启动需要一个开机广播。
- android开机自启动的后台Service的实现
- android开机自启动的后台Service的实现 .
- android开机自启动的后台Service的实现
- android 后台service开机自启动
- Android实现开机自启动Service
- Android实现开机自启动Service
- Android实现开机自启动Service
- Android 实现开机自启动 Service
- Android实现开机自启动Service
- Android实现开机自启动Service
- Android实现开机自启动Service
- Android如何实现开机自启动Service
- android实现应用程序的开机自启动
- Android实现应用程序的开机自启动
- android实现应用程序的开机自启动
- android实现项目的开机自启动
- 初学Android,开机自启动的Service(七十三)
- Android系统广播大全及开机自启动的Service
- FPGA与CPLD区别
- java security week
- linux学习问题
- 导入Excel数值读不到,找不到可安装的 ISAM错误!(导入Excel常见错误)
- HTML学习笔记02(HTML 标签)
- android开机自启动的后台Service的实现
- linux下获取键盘按键
- Servlet运行周期与原理流程
- CocoaPacketAnalyzer的使用方法
- 字符编码问题之手动转码并不万能
- 如何安装,卸载eclipse中的ADT,或者更新ADT
- 使用金山快盘做git的服务器
- 原创利用flashpaper实现百度文库、豆丁网文档预览功能
- error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const