Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Launching or bringing to front another application via Intent

Im having trouble getting this to work, here´s a quick overview of the idea.

First, I cant change the logic behind this, it was a specific requirement from the customer, I realize that with any tool such as AnyCut it could be bypassed but that doesnt matter really.

My customer offers a suite of apps, the idea is that all applications bellonging to the suite would be launched from a "Dashboard app", so that I only show the Dashboard app in the main launcher and not all app icons.

Lets take two Apps to get the idea solved. The Dashboard App (A) and the Recieving App (B).

I want to establish an intent filter (I think) on app B so that whenever I go into app A, and click the app B icon the app will be either launched or started from where it let of (brought to front).

Is this even possible? If so, how can I do it? I managed to get it to launch by specifically launching one activity in the app using:

Intent i = new Intent();
i.setClassName("PACKAGE_NAME","SPECIFIC_CLASS");
startActivity(i);

But that isnt the behaviour that I want, as it always starts app B in the same spot.

Thanx in advance, Stefano

Edit: Added some new information. I was taking a look at the DDMS.

If I launch the application from scratch through the main Android launcher the intent is exactly the same as when I leave the home button pressed and then only bring the app to front, what ever activity im in. So I was trying to reproduce, unsucsesfully until now, this intent.

INFO/ActivityManager(1292): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.package/.uiPackage.Activity}

This is how AnyCut does it

Intent { act=android.intent.action.VIEW flg=0x10000000 cmp=com.example.package/.uiPackage.Activity bnds=[125,242][235,360]}

Any idea how I could go about creating that exact same intent? I cant even find that flag in the Intent API.

like image 304
blindstuff Avatar asked Feb 03 '11 22:02

blindstuff


1 Answers

Figured it out, this is how I did it.

Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setAction("android.intent.action.VIEW");
i.setComponent(ComponentName.unflattenFromString("com.example.package/com.example.package.activityName"));
startActivity(i);
like image 117
blindstuff Avatar answered Nov 07 '22 03:11

blindstuff