Are you trying to launch an activity that you created, or an arbitrary third
party app?

Thanks,
Justin
----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Fri, Sep 18, 2009 at 7:46 AM, Abhi <[email protected]> wrote:

>
> Hi,
>
> After searching through some online and the package manager methods, I
> came across ApplicationInfo and a way to open an app activity using
> this as below:
>
> ApplicationInfo ai
> PackageManager pm = getPackageManager();
> try {
>    Intent i = pm.getLaunchIntentForPackage(ai.packageName);
>    startActivity(i);
>    }
> catch (Exception e) {
>    Toast t = Toast.makeText(this, "Couldn't launch the application.",
> Toast.LENGTH_SHORT);
>    t.show();
> }
>
> However, I need to have the application info in 'ai' to make the above
> code work... I don't seem to understand how ApplicationInfo works on a
> particular app. Help please!!!
>
> Abhi
>
> On Sep 18, 8:25 am, Mark Murphy <[email protected]> wrote:
> > Abhi wrote:
> > > Thanks Mark.
> >
> > > Can you give an example for launching the Youtube app from within my
> > > app? I have tried startActivity() to open up Gallery this way:
> >
> > > Intent intent2 = new Intent();
> > > intent2.setClassName("com.android.camera",
> > > "com.android.camera.GalleryPicker");
> > > intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> > > startActivity(intent2)
> >
> > > Couldn't understand how to do it with other apps.
> >
> > You will need to use methods on PackageManager to determine an
> > appropriate activity to use for that package.
> > getLaunchIntentForPackage() is probably worth trying.
> >
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|
> http://twitter.com/commonsguy
> >
> > Android 1.5 Programming Books:http://commonsware.com/books.html
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to