Android and android Official Website

Source: Internet
Author: User

Android and android Official Website
Determine the specific action of intent-filter


Address: http://blog.csdn.net/caroline_wendy


If you useStartIntent () Start ActivityIfIntent-filter does not include this action, The system will crash abnormally. You can check before using it:

// Determine whether to install the [health tool] private boolean isInstallChunyuTools () {Intent cardioFaceIntent = new Intent (EtonConstants. CHUNYU_CARDIO_FACE_ACTION); Intent pedometerIntent = new Intent (EtonConstants. CHUNYU_PEDOMETER_ACTION); PackageManager pm = getPackageManager (); List <ResolveInfo> cardioFaceInfos = pm. queryIntentActivities (cardioFaceIntent, PackageManager. GET_RESOLVED_FILTER); List <ResolveInfo> pedometerInfos = pm. queryIntentActivities (pedometerIntent, PackageManager. GET_RESOLVED_FILTER); return cardioFaceInfos. isEmpty () | pedometerInfos. isEmpty ();}


Reference: http://stackoverflow.com/questions/20809237/android-search-installed-package-with-intent-filter
Heck 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);}





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.