1

When i try to take a picture the app is crashing.

static var:

    static final int REQUEST_IMAGE_CAPTURE = 1;

function call:

    btnCapturePicture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dispatchTakePictureIntent();
        }
    });

function:

private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }
}

manifest:

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

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 <uses-permission android:name="android.permission.RECORD_AUDIO" />
 <uses-permission android:name="android.permission.CAMERA" />
 <uses-permission android:name="android.permission.INTERNET" />

The crash happens when i click the btnCapturePicture button. The app is webview base app, when clicking on webview button it starts the activity which contains the codes i have posted.

Thanks for any help.

Solution that worked for me: removing this line from the manifest:

<uses-permission android:name="android.permission.CAMERA" />

And make sure you have this line:

<uses-feature android:name="android.hardware.camera" android:required="true" />
net-User
  • 25
  • 6

1 Answers1

0

What worked for me:

removing this line from the manifest:

<uses-permission android:name="android.permission.CAMERA" />

And make sure you have this line:

<uses-feature android:name="android.hardware.camera" android:required="true" />
net-User
  • 25
  • 6