0

I am getting an error when accessing camera the error is

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 clip={text/uri-list {...}} (has extras) }

this is where the error occurs

   try {
        val intent = Intent("android.media.action.IMAGE_CAPTURE")
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mUri)
        startActivityForResult(intent, CAMERA_REQUEST_CODE)
   } catch (exception: Exception) {
        Log.d("errorCamera", "${exception}")
        exception.printStackTrace()
   }

Min and target sdk version are

    minSdkVersion(23)
    targetSdkVersion(30)

Please suggest what I might be doing wrong here.

greybeard
  • 2,249
  • 8
  • 30
  • 66
BRDroid
  • 3,920
  • 8
  • 65
  • 143
  • Does this help you : https://stackoverflow.com/questions/49435522/error-no-activity-found-to-handle-intent-act-android-media-action-image-capture – Abhishek Dutt Mar 14 '22 at 09:58
  • Hello @AbhishekDutt I had a look at that, but was not sure what changes I need to make to my code – BRDroid Mar 14 '22 at 10:03
  • could you suggest what changes I need to make in my code which might resolve please – BRDroid Mar 14 '22 at 10:03

2 Answers2

1

I think the problem is that you need to create an activity that will use the camera feature. And also add some permissions to the manifest file, like this for example:

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

I'll leave you some resources here (hope it helps):

greybeard
  • 2,249
  • 8
  • 30
  • 66
0

I guess you should use this Intent for taking picture:

val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
Sam Chen
  • 7,597
  • 2
  • 40
  • 73