Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Starting an application from an ApplicationInfo instance

If I have an ApplicationInfo instance of a particular app, how can I make an Intent to launch the app?

I tried

Intent intent = new Intent(ApplicationInfoInstance.packageName);

but it gives an exception. The app is installed so the exception is not due to that.

I think I need to use

setClassName (String packageName, String className);

Could someone direct me to obtain these two values? Because most of my apps returns NULL for ApplicationInfoInstance.className;

Thank you.

like image 305
madu Avatar asked Dec 25 '10 15:12

madu


People also ask

How do I launch an app using package name?

Just use these following two lines, so you can launch any installed application whose package name is known: Intent launchIntent = getPackageManager(). getLaunchIntentForPackage("com. example.


1 Answers

If I have an ApplicationInfo instance of a particular app, how can I make an Intent to launch the app?

There is no such thing as "launch the app" in Android. An "app" may have zero, one, or several activities that are in the launcher and are designed to be launched.

You should be able to use getLaunchIntentForPackage() on PackageManager to get an Intent that meets your needs (or null if there is no such Intent).

like image 164
CommonsWare Avatar answered Sep 29 '22 17:09

CommonsWare