No Activity found to handle MediaStore.ACTION_IMAGE_CAPTURE Intent

人走茶凉 提交于 2019-12-23 04:46:13

问题


I am using this quite simple piece of code to capture an image on an Android device.

File tmpFile = ...;
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile));
startActivityForResult(intent, CAPTURE_IMAGE);

This works fine for thousands of users except for one running this on a Kindle device without camera. Today I got a crash report from a device with camera:

ANDROID_VERSION=4.2.1
BRAND=Hisense
PHONE_MODEL=M470BSA
STACK_TRACE=android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.media.action.IMAGE_CAPTURE (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
at android.app.Activity.startActivityForResult(Activity.java:3370)
at android.app.Activity.startActivityForResult(Activity.java:3331)
...

I have put some exception handling around the code to catch the exception and show an error, but I have no idea why this piece of code is failing on this device. The user confirmed that the camera is working fine.


回答1:


First, there is no requirement that a device have an activity that supports ACTION_IMAGE_CAPTURE, even if the device has an actual camera.

Second, particularly on Android 4.3+ tablets, the person using the device may not have access to an ACTION_IMAGE_CAPTURE activity, even if one is installed, as the person may be running in a restricted profile.



来源:https://stackoverflow.com/questions/18902086/no-activity-found-to-handle-mediastore-action-image-capture-intent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!