문제

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 {
...
}
도움이 되었습니까?

해결책

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top