I already searched on stackoverflow and found very useful answers but none of them worked for me. Iam trying to access the webcam of my laptop through the emulator from android studio.
This is my code :
@Override
public void onClick(View v) {
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI.getPath());
startActivityForResult(intent, 1);
}
i also added the following permissions :
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera"/>
i also enabled in avd the following settings :
Camera : Front set to WebCam0
and Back set to WebCam0
The error i am getting is :
java.lang.SecurityException: Permission Denial: starting Intent {
act=android.media.action.IMAGE_CAPTURE cmp=com.android.camera/.Camera
(has extras) } from ProcessRecord{8f8626
3870:com.example.felix.eitimer/u0a57} (pid=3870, uid=10057) with
revoked permission android.permission.CAMERA
Maybe someone knows the answer, i find it quite strange since, EVERY tutorial about it, explains what i have tried so far.