user2341387
user2341387

Reputation: 303

Android: Search installed package with Intent filter

I don't know if this questing ever asked before, tried to search and found nothing.

Is that possible to search and display installed package by checking it's manifest if contains specific intent filter?

Ex: I want to display installed package that contains custom Intent Filter on it's manifest

<intent-filter>
      <action android:name="com.example.one" />
</intent-filter>

As a sample, then if application is exist, I want to make a text "Application Exist" on a textview

if (...//checking if application exist or not) {
      textview.setText("Application Exist");
}
else {
...
}

Upvotes: 0

Views: 1880

Answers (1)

Greg Giacovelli
Greg Giacovelli

Reputation: 10184

Check out queryIntentActivities()

So you create an intent with the correct filter matching discriminators on it.

Intent intent = new Intent("my_awesome.package.hasa.custom.ACTION!");
intent.addCategory("typingisfunfunfun");
intent.setData(Uri.parse("data://foo/bar"));
PackageManager pm = getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER);
if(resolveInfo.isEmpty()) {
  Log.i("NoneResolved", "No Activities");
} else {
  Log.i("Resolved!", "There are activities" + resolveInfos);
}

Upvotes: 2

Related Questions