Android 2.2: How to get an application to start automatically at startup and how to get an application to launch another application

The topic pretty much talks about all this.

+4
source share
2 answers

Use the BroadcastReceiver , which receives the BOOT_COMPLETED action.

in the onReceive () method, create an intent for your activity:

 @Override public void onReceive(Context context, Intent intent) { Intent myIntent = new Intent(context, YourActivity.class); context.startActivity(myIntent); } 
+4
source

For the application at startup you need to add permission

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 

to your manifest. Then do as Vladimir wrote.

To launch another application, you need to know (officially, I hope) the intention to launch it. Otherwise, see My answer to the question triggers an action that is in another package (Android)

For example, launching the LastFM application would be like this:

 final Intent i = new Intent("android.intent.action.MAIN"); i.setComponent(new ComponentName("fm.last.android","fm.last.android.LastFm")); startActivity(i); 
+3
source

Source: https://habr.com/ru/post/1333669/


All Articles