EACCES (Permission denied) in using Camera Android -


i want , storage photo android camera. code:

public void avviafotocamera(view v){         this.launchcamera();     }      private void launchcamera() {         try {             moutputfile = new file(getexternalstoragedirectory(),  "temp.jpg");             intent intentcamera = new intent(android.provider.mediastore.action_image_capture);             intentcamera.putextra(mediastore.extra_output,                     uri.fromfile(moutputfile));             startactivityforresult(intentcamera, camera_request);         }   catch (exception e) {             toast t = toast.maketext(this, "si è verificato un errore durante l'acquisizione dell'immagine:\n" + e.tostring(), toast.length_long);             t.show();         }     }          @override         protected void onactivityresult(int requestcode, int resultcode, intent data) {              if(requestcode == camera_request) {                 try {                     bitmap datifoto = android.provider.mediastore.images.media.getbitmap(this.getcontentresolver(),                                       uri.fromfile(moutputfile));                     savebitmap(datifoto);                     moutputfile.delete();                 }   catch (exception e) {                     toast t = toast.maketext(this, "si è verificato un errore durante l'acquisizione dell'immagine:\n" + e.tostring(), toast.length_long);                     t.show();                 }             }         }      private void savebitmap(bitmap datifoto) {         try {             //nome del file da assegnare all'immagine             final string filename = "prova.jpg";             fileoutputstream out = new fileoutputstream(getexternalstoragedirectory ()+filename);             datifoto.compress(bitmap.compressformat.jpeg, 90, out);         }   catch (exception e) {             toast t = toast.maketext(this, "si è verificato un errore durante il salvataggio dell'immagine:\n" + e.tostring(), toast.length_long);             t.show();             e.printstacktrace();         }     } 

however error: java.io.filenotfoundexception: /prova.jpg: open failed: eacces (permission denied). manifest add required permissions:

 <uses-sdk         android:maxsdkversion="22"         android:minsdkversion="15"         android:targetsdkversion="15" />      <uses-permission         android:name="android.permission.write_external_storage"         android:maxsdkversion="22" />     <uses-permission android:name="android.permission.read_phone_state" />     <uses-permission         android:name="android.permission.read_external_storage"         android:maxsdkversion="22" />     <uses-permission android:name="android.permission.set_debug_app" />     <uses-permission android:name="android.permission.camera" />     <uses-permission android:name="android.permission.access_network_state" />     <uses-permission android:name="android.permission.read_contacts"/>     <uses-feature android:name="android.hardware.camera"/>     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.access_coarse_location" />     <uses-permission android:name="android.permission.access_fine_location" />     <uses-permission android:name="com.javapapers.android.maps.path.permission.maps_receive" />     <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" />     <uses-permission android:name="android.permission.mount_unmount_filesystems" />   

how can fix it??

it appears you're trying save file /prova.jpg, in root directory of device. app can't store files there. appears line isn't working expected:

fileoutputstream out = new fileoutputstream(getexternalstoragedirectory ()+filename); 

perhaps try:

file outfile = new file(environment.getexternalstoragedirectory(), "prova.jpg"); fileoutputstream out = new fileoutputstream(outfile); 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -