1

In my application, i start another application (not activity) with this code :

protected void launchApp(String packageName) {
    Intent mIntent = getPackageManager().getLaunchIntentForPackage(
            packageName);
    if (mIntent != null) {
        try {
            startActivity(mIntent);
        } catch (ActivityNotFoundException err) {
            Toast t = Toast.makeText(getApplicationContext(),
                    "App not found", Toast.LENGTH_SHORT);
            t.show();
        }
    }
}

but i would like this application (launched by packageName) run in background and not disturb the UI.

Is it possible ?

Thanks!

Yoplaboom
  • 554
  • 3
  • 13
  • 1
    Depends on the application that you launch. There is no way for you to forcibly I.e. launch a new Skype activity in the background. – mach Sep 18 '14 at 09:24
  • Ok thanks for your answer, i wasn't sure if that was possible. – Yoplaboom Sep 18 '14 at 09:43
  • 2
    I've been thinking. It might be possible if you launch the new app and at the same time schedule a launch intent back to your own app using the AlarmManager. Just put 100ms delay on it. A bit of a clutch but it might work. – mach Sep 18 '14 at 10:15

1 Answers1

0

You can use a broadcast receiver in the target app and start it by broadcast.

startActivity(getPackageManager().getLaunchIntentForPackage("com.example.appName"));

For further information please see this.

Dr.jacky
  • 3,341
  • 6
  • 53
  • 91