Permission Denial: starting Intent with revoked permission android.permission.CAMERA [duplicate]

0

Code to call camera

 public void TirarFoto() {
    final Random numRandomico = new Random();
    String resultado = String.valueOf(numRandomico.nextInt(20));
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    File photo = new File(Environment.getExternalStorageDirectory(), resultado + "ImgAndroid.jpg");
    intent.putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(photo));
    imageUri = Uri.fromFile(photo);
    startActivityForResult(intent, TAKE_PICTURE);  <- está parando aqui
}

When I call it the following error is appearing

04-07 14:33:14.367 9261-9261/br.com.patrulha E/AndroidRuntime: FATAL EXCEPTION: main
   Process: br.com.patrulha, PID: 9261
   java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.sec.android.app.camera/.Camera clip={text/uri-list U:file:///storage/emulated/0/13ImgAndroid.jpg} (has extras) } from ProcessRecord{aa1b01c 9261:br.com.patrulha/u0a306} (pid=9261, uid=10306) with revoked permission android.permission.CAMERA
       at android.os.Parcel.readException(Parcel.java:1620)
       at android.os.Parcel.readException(Parcel.java:1573)
       at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3130)
       at android.app.Instrumentation.execStartActivity(Instrumentation.java:1540)
       at android.app.Activity.startActivityForResult(Activity.java:4283)
       at android.app.Activity.startActivityForResult(Activity.java:4230)
       at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)
       at br.com.patrulhar.Cadastrar_Alerta.TirarFoto(Cadastrar_Alerta.java:295)
       at br.com.patrulhar.Cadastrar_Alerta$5.onClick(Cadastrar_Alerta.java:509)
       at android.view.View.performClick(View.java:5697)
       at android.widget.TextView.performClick(TextView.java:10826)
       at android.view.View$PerformClick.run(View.java:22526)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:158)
       at android.app.ActivityThread.main(ActivityThread.java:7224)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I declared in androidmanifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

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

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
    
asked by anonymous 07.04.2016 / 19:36

1 answer

-1

I do not know if that's the case, but from Lollipop, changed the way Android requests the user's permission. Try adding it to your AndroidManifest.xml

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" />
    
07.04.2016 / 22:21