【发布时间】:2010-12-30 20:58:58
【问题描述】:
这个话题几乎说明了一切。
【问题讨论】:
标签: java android autostart bootcompleted
这个话题几乎说明了一切。
【问题讨论】:
标签: java android autostart bootcompleted
使用BroadcastReceiver 接收动作意图BOOT_COMPLETED。
在 onReceive() 方法中为您的活动创建一个 Intent:
@Override
public void onReceive(Context context, Intent intent) {
Intent myIntent = new Intent(context, YourActivity.class);
context.startActivity(myIntent);
}
【讨论】:
对于启动时的应用,需要添加权限
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
到您的清单。 然后按照弗拉基米尔写的去做。
要启动另一个应用程序,您需要知道(希望是官方的)启动它的意图。否则请参阅我对问题的回复 calling an activity that is in another package(android)
例如,启动 LastFM 应用程序是这样的:
final Intent i = new Intent("android.intent.action.MAIN");
i.setComponent(new ComponentName("fm.last.android","fm.last.android.LastFm"));
startActivity(i);
【讨论】: