Home > Net >  How to resolve No Activity found to handle Intent
How to resolve No Activity found to handle Intent

Time:03-15

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.

CodePudding user response:

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):

CodePudding user response:

I guess you should use this Intent for taking picture:

val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
  • Related