Android 台灣中文網
標題:
android手機開機自動啟動程序
[打印本頁]
作者:
暗桌之光
時間:
2011-6-26 14:50
標題:
android手機開機自動啟動程序
最近的需要一個程序在手機開機之後,能夠自動啟動。android可以是實現開機自啟動程序,就是通過繼承android.content.BroadcastReceiver來實現廣播,從而實現開機啟動這個應用程序.
主要自啟動代碼是:
package com.easymorse;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class HippoStartupIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent mBootIntent = new Intent(context, myboot.class);
mBootIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(mBootIntent);
}
}
複製代碼
上面的代碼還不能實現程序開機自啟動,主要在AndroidManifest.xml配置文件中添加filter:
<receiver android:name="HippoStartupIntentReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
複製代碼
才能實現開機自啟動程序。
開機自啟動手機真靈程序源代碼:
https://easymorse-android.googlecode.com/svn/trunk/MyBoot
作者:
hihiman1985
時間:
2011-9-27 07:58
老大~~求求你教教我~該怎麼做吧~~我的電腦不裡我的電話~~我的電話也在鬧皮氣~我真不知道該如何是好阿~~
歡迎光臨 Android 台灣中文網 (https://apk.tw/)
Powered by Discuz! X3.1