Posted By

abwaters on 06/07/09


Tagged

android intent


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

edouardmercier


Determine if Intent Receiver Exists in Android


 / Published in: Java
 

URL: http://android-developers.blogspot.com/2009/01/can-i-use-this-intent.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. }

Report this snippet  

You need to login to post a comment.