how to lauch an 3rd application automatically when the android phone is switched on
Thanks in Advance,
you need an implementation of BroadcastReceiver
, which is intended on BOOT_COMPLETED
action. Like this:
public class OnStartReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Runtime.getRuntime().exec("your command");
// but it is better here to do that:
Intent myIntent = new Intent(context, YourActivity.class);
context.startActivity(myIntent);
}
}
Also, you should add receiver
tag to your manifest file with android:name
= your fully qualified name of OnStartReceiver and intent-filter tag nested with BOOT_COMPLETED
as intent name, like this:
<receiver android:name=".onStartReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver >
精彩评论