user3076750 user3076750 - 2 months ago 21
Java Question

Android No Activity found - STILL_IMAGE_CAMERA

I am getting the following exception in my android app.

No Activity found to handle Intent { act=android.media.action.STILL_IMAGE_CAMERA (has extras) }


I know that my device, an MC70, has a camera.

bool hasFeature = packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA);
int numCameras = android.hardware.Camera.getNumberOfCameras();


Both hasFeature is true and numCameras > 0

The device has an SD card installed:

Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);


In the AndroidManifest.xml file I have:

<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.CAMERA" />


final PackageManager packageManager = context.getPackageManager();

This list comes back empty, probably a bad sign:

final Intent intent = new Intent(action);

List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);


This code must run on the MC70, which is limited to KitKat 4 API 19.

But when I call:

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, 1);


I get the exception:

No Activity found to handle Intent { act=android.media.action.STILL_IMAGE_CAMERA_SECURE (has extras) }


I have tried:


  • MediaStore.ACTION_IMAGE_CAPTURE

  • MediaStore.ACTION_IMAGE_CAPTURE_SECURE

  • MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA

  • MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE



All throw the exception. Why?

Answer

Why?

Because the device manufacturer did not install a camera app that supports any of those Intent structures. If the device does not legitimately ship with the Play Store on it, there is no requirement that the manufacturer have to meet any particular compatibility requirements.

Assuming that you do not need a camera app with any particular features, install an open source one, like Open Camera, so your device has an app that responds to ACTION_IMAGE_CAPTURE, etc.