lundi 4 mai 2015

Check activity for crop intent exists

On some devices i got exception:

E/AndroidRuntime(11315): Process: com.google.android.GoogleCamera, PID: 11315 E/AndroidRuntime(11315): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.camera.action.CROP dat=file:///data/data/com.google.android.GoogleCamera/files/crop-temp (has extras) }

I have two devices and experimentally checked that on the first i.putExtra("crop", "true"); works, on second one get exception like above. To avoid this exception i'm trying to make some check, before using crop functionality, but always get false from my checkIntent method. Is something missed ?

 Intent i = new Intent("com.android.camera.action.CROP");
 final boolean cropOK = AppUtils.checkIntent(getActivity(), i);

...

  public static boolean checkIntent(Context context, Intent intent) {
        PackageManager manager = context.getPackageManager();
        List<ResolveInfo> infos = manager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
        return infos.size() > 0;
    }

Aucun commentaire:

Enregistrer un commentaire