Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch another app in the background? [closed]

I'm launching my app on boot up but I want it to start up in the background.

Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("my.app");
if (launchIntent != null) {
   context.startActivity(launchIntent);//null pointer check in case package name was not found
}

Any idea how to do that without the app start up in the foreground?

like image 332
the_prole Avatar asked Feb 02 '26 04:02

the_prole


1 Answers

Theoretically an app majorly consists of two components.

  1. Activity : Runs in foreground which is mainly a GUI for an app and user interacts with activity as it take inputs from user and displays required results.

  2. Service: Runs in background which does all the operations required by activity to produce results by receiving the inputs from activity(user) and send back the results to activity for displaying them.

So, your question of starting an app in background ! This can be achieved by starting a service of your app on boot up and carry out tasks which you want to perform.

P.s : To start a Service on boot-up, you will require to set up a Boot-Receiver. If you want any further information regarding this, please let me know.

like image 150
Androwed Avatar answered Feb 04 '26 22:02

Androwed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!