Finding out if an intent is available
Sometimes you want to find if an application has registered for a certain intent. For example you want to check if a certain holding er is available and if you enable some functionality in your app.
Sometimes you want to know whether a certain AP has registered a clear intent. For example, you want to check whether a certain receiver exists, then, enable some functions in your AP based on whether the hacker exists.
This can be done via checking the packagemanager. The following code checks if an intent exists. You can check via this method for intent and change your application behavior accordingly for example disable or hide menu items.
You can check packagemanager.CodeCheck whether an intent exists.
Public Boolean isintentavailable (context, string action) {final packagemanager = context. getpackagemanager (); Final intent = new intent (action); List <resolveinfo> resolveinfo = packagemanager. queryintentactivities (intent, packagemanager. match_default_only); If (resolveinfo. size ()> 0) {return true;} return false ;}
This articleArticleIt is a bit similar to the previousDetermine whether an AP exists in the system (packagemanager and packageinfo)
translated from; http://www.vogella.de/articles/AndroidIntent/article.html