Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - check for presence of another app

Tags:

android

I'm working on an app that extends the functionality of another, existing app. I want to know what the easiest way is to determine, through code, whether the first app is installed, preferably by referencing it by com.whoever.whatever but almost any criteria would be helpful.

like image 285
David Perry Avatar asked Sep 12 '10 08:09

David Perry


People also ask

Can an Android app read data from another app?

There are three ways your app can receive data sent by another app: An Activity with a matching intent-filter tag in the manifest. One or more ChooserTarget objects returned by your ChooserTargetService.

How do you check if app is installed or not in Android programmatically?

Call the method isPackageInstalled() : boolean isAppInstalled = isPackageInstalled("com. android. app" , this.

How do I tell what services are running on my Android?

Back in Settings, head into Developer Options. You should see “Running services” a little way down this menu—that's what you're looking for. Once you tap “Running services,” you should be presented with a familiar screen—it's exactly the same one from Lollipop.


2 Answers

android.content.pm.PackageManager mPm = getPackageManager();  // 1
PackageInfo info = mPm.getPackageInfo(pName, 0);  // 2,3
Boolean installed = info != null;

  1. Used in an activity, you need a context to get the PackageManager
  2. Throws PackageManager.NameNotFoundException, I guess. check!
  3. pName is something like 'com.yourcompany.appname', the same as the value of 'package' in the manifest of the app
like image 106
Reza Mohammadi Avatar answered Oct 20 '22 08:10

Reza Mohammadi


The recommended way is to check whether the other application publishes an Intent. Most Intent are not owned by a particular app, so, say, if you're looking for a program that publishes "sending mail" intent, the program that gets opened may be Gmail application or Yahoo Mail application, depending on the user's choice and what was installed in the system.

You may want to look at this: http://developer.android.com/guide/topics/intents/intents-filters.html

like image 41
Lie Ryan Avatar answered Oct 20 '22 08:10

Lie Ryan