Determine if Intent Receiver Exists in Android


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2.  * Indicates whether the specified action can be used as an intent. This
  3.  * method queries the package manager for installed packages that can
  4.  * respond to an intent with the specified action. If no suitable package is
  5.  * found, this method returns false.
  6.  *
  7.  * @param context The application's environment.
  8.  * @param action The Intent action to check for availability.
  9.  *
  10.  * @return True if an Intent with the specified action can be sent and
  11.  * responded to, false otherwise.
  12.  */
  13. public static boolean isIntentAvailable(Context context, String action) {
  14. final PackageManager packageManager = context.getPackageManager();
  15. final Intent intent = new Intent(action);
  16. List<ResolveInfo> list =
  17. packageManager.queryIntentActivities(intent,
  18. PackageManager.MATCH_DEFAULT_ONLY);
  19. return list.size() > 0;
  20. }

URL: http://android-developers.blogspot.com/2009/01/can-i-use-this-intent.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.