Thierry Legras wrote:
> How can i start an application just knowing the package name, not the
> classname?

There is no concept in Android of "start an application". There is
"start an activity", even "start an activity that appears in the Launcher".

> Ok, there is Intent.setComponent solution would be what i need ... if it
> was compatible with 1.5 :(

Not to mention the fact that this will not work by itself.

BTW, setComponent() most certainly works with Android 1.5, since that
method existed since API Level 1 (a.k.a., Android 1.0).

> I guess i have to play with getPackageManager() but how can i use it?

Intent i=new Intent(Intent.ACTION_MAIN);

i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(name);

startActivity(i);

See:

http://github.com/commonsguy/cw-advandroid/tree/master/Introspection/Launchalot/

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to