开发者

how to lauch an 3rd application automatically when the android phone is switched on

开发者 https://www.devze.com 2023-01-31 05:37 出处:网络
can any one tell me \"how to lauch an 3rd application automa开发者_运维问答tically when the android phone is switched on?\". As I want to launch an application which is written by me when the device

can any one tell me "how to lauch an 3rd application automa开发者_运维问答tically when the android phone is switched on?". As I want to launch an application which is written by me when the device is turned on.

I will be waiting for any valuable reply .

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 >
0

精彩评论

暂无评论...
验证码 换一张
取 消