1

I want to launch my other app from my application and then return back to the first application.

For example:
I have app with contacts, I want to send an email to selected contact with my company's app, click on email address, open my other installed app, write text and send it.. And then I need to return back to previous application with contacts.

I'm using this solution:

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);

from: Launch an application from another application on Android

It launches email app from my first app, unfortunately there is no way to return back to the first application without kill first app in app manager.

When I tried open first app again from app maganer or app icon - it launches second (email) application again

Community
  • 1
  • 1
Sandak
  • 2,212
  • 7
  • 23
  • 48

3 Answers3

1

please try this:

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
LaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(LaunchIntent);
Milad Faridnia
  • 8,038
  • 13
  • 63
  • 69
0
  1. Make your lanucher Activity of 1st app as SingleTop.
  2. launch first application
  3. launch 2nd application from first.
  4. launch again first application from 2nd one,
Noor Nawaz
  • 2,007
  • 22
  • 34
  • Thank you for your answer.. Unfortunately it doesn't open my first app where user left it.. In other words, it opens first app from launcher activity. Or what if user wants to go back to first app without closing second app? In my opinion there is something wrong with intent code, maybe there is something missing to tell android what I want to do? – Sandak Dec 06 '14 at 16:10
0

Along with making launcher activity SingleTop, you have to override the onNewIntent method in your main activity. onNewIntent is meant as entry point for SingleTop activities which are already running. This will help to return back to your first application in the same state that you left it.

Queen
  • 138
  • 1
  • 8