Here's a class that i use in one of my apps to detect if a package is installed when my service starts up. You should be able to modify this to suit your needs.
public class AppDetector { protected boolean isAppInstalledFromService(Service parent, String uri) { PackageManager pm = parent.getPackageManager(); boolean installed = false; try { pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); installed = true; } catch (PackageManager.NameNotFoundException e) { installed = false; } return installed; } } To call it: AppDetector detect = new AppDetector(); Boolean isInstalled = detect.isAppInstalledFromService(this, " com.your.package.name"); //Nick On Thu, Jul 22, 2010 at 8:39 AM, Justin Anderson <janderson....@gmail.com>wrote: > Use the PackageManager class: > > http://developer.android.com/reference/android/content/pm/PackageManager.html > > ---------------------------------------------------------------------- > There are only 10 types of people in the world... > Those who know binary and those who don't. > ---------------------------------------------------------------------- > > > > On Thu, Jul 22, 2010 at 9:33 AM, Jake Colman <col...@ppllc.com> wrote: > >> >> When my user clicks on my AppWidget, I want to launch either my own >> provided activity or an activity from a different app if that app is >> installed. My own activity is a stripped down version of the >> information that can be displayed by that other application. If that >> other application is available, I'd prefer to launch it in instead of my >> own. I may include this as a preference option and allow the user to >> decide which activity to launch. >> >> How can I check whether a specific app is installed before attempting to >> launch it (or before including it in my preferences) and only launch my >> own activity if that app is not available? >> >> Thanks. >> >> ...Jake >> >> -- >> Jake Colman -- Android Tinkerer >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Beginners" group. >> >> NEW! Try asking and tagging your question on Stack Overflow at >> http://stackoverflow.com/questions/tagged/android >> >> To unsubscribe from this group, send email to >> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/group/android-beginners?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- //Nick Richardson //richardson.n...@gmail.com -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en