Shasi
Shasi

Reputation: 274

Open another application's activity in the Same Task?

For example, when I open Facebook Login page from an application that screen (activity) is loaded in the same Task stack.

In the same way, I want to open an activity of another application from my application, to be loaded in the same Task Stack, not starting New Task.

Normally, when we access other application we use "FLAG_ACTIVITY_NEW_TASK", which creates new task.

But How do I load the other application's activity in the same Task ?

Targeted new application is not android built-in Intent activities (like email, contact, call etc.)

I am trying to open activity of my another application from one application.

UPDATE

I think I couldnt make it enough clear. I have application A and Application B installed in device, both apps made by me, not system built. Now I want to access main_activity of Application B from an activity of application A, and still remain in the same Task. Thanks

Upvotes: 2

Views: 4044

Answers (2)

Snehasis Maity
Snehasis Maity

Reputation: 25

for inbulit mail application :

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL  , new String[]{"[email protected]"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT   , "Content");
try {
    startActivity(Intent.createChooser(intent, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "No email clients installed.", Toast.LENGTH_SHORT).show();
}

Upvotes: -2

CommonsWare
CommonsWare

Reputation: 1007554

But How do I load the other application's activity in the same Task ?

First, do not use FLAG_ACTIVITY_NEW_TASK. This says that you do not want a new task.

Second, ensure that the activity that you are starting does not have a taskAffinity or launchMode that would interfere with this.

So, for example, startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS)); will start the date-and-time Settings screen in your task. Most Settings screens have a taskAffinity, where this would still wind up in a separate task.

Upvotes: 4

Related Questions