Issue
I know how to update my own programs, and I know how to open programs using the a predefined Uri (for sms or email for example)
I need to know how I can create an Intent to open MyTracks or any other application that I don't know what intents they listen to.
I got this info from DDMS, but I havn't been succesful in turning this to an Intent I can use. This is taken from when opening MyTracks manually.
Thanks for your help
05-06 11:22:24.945: INFO/ActivityManager(76): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.google.android.maps.mytracks/com.google.android.apps.mytracks.MyTracks bnds=[243,338][317,417] }
05-06 11:22:25.005: INFO/ActivityManager(76): Start proc com.google.android.maps.mytracks for activity com.google.android.maps.mytracks/com.google.android.apps.mytracks.MyTracks: pid=1176 uid=10063 gids={3003, 1015}
05-06 11:22:26.995: INFO/ActivityManager(76): Displayed activity com.google.android.maps.mytracks/com.google.android.apps.mytracks.MyTracks: 1996 ms (total 1996 ms)
Solution
Firstly, the concept of "application" in Android is slightly an extended one.
An application - technically a process - can have multiple activities, services, content providers and/or broadcast listeners. If at least one of them is running, the application is up and running (the process).
So, what you have to identify is how do you want to "start the application".
Ok... here's what you can try out:
- Create an intent with
action=MAIN
andcategory=LAUNCHER
- Get the
PackageManager
from the current context usingcontext.getPackageManager
packageManager.queryIntentActivity(<intent>, 0)
where intent hascategory=LAUNCHER
,action=MAIN
orpackageManager.resolveActivity(<intent>, 0)
to get the first activity with main/launcher- Get the
ActivityInfo
you're interested in - From the
ActivityInfo
, get thepackageName
andname
- Finally, create another intent with with
category=LAUNCHER
,action=MAIN
,componentName = new ComponentName(packageName, name)
andsetFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- Finally,
context.startActivity(newIntent)
Answered By - gvaish