J'ai l'erreur lors du remplacement de l'image de capture par un bitmap converti en image.Fichier d'image multimédia Bloqué et autorisation refusée dans nougat
Intent intent =new Intent(this,Myclass.class);
intent.setData(params[0]);
sendBroadcast(intent);
dans la classe de diffusion
Uri uri=intent.getData();
Copie Méthode
private File CopyImage(String sourcepath, String targetpath) {
File sourceLocation = new File(sourcepath);
File targetLocation = new File(targetpath);
InputStream in = null;
OutputStream out = null;
try {
in = new FileInputStream(sourceLocation);
out = new FileOutputStream(targetLocation);
// Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
return targetLocation;
}
Quand je le TargetPath accèdent
content://media/external/images/media/19392?blocking=1&orig_id=19392&group_id=0
Permission accordée
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
'Bitmap Image = Uri.getData()' ne compilera pas, comme [ 'Uri' ne dispose pas d'une méthode' 'getData()] (https: //developer.android.com/reference/android/net/Uri.html). Donc, veuillez fournir un [mcve], avec la trace de pile Java complète associée à votre erreur et le code * réel * qui a généré cette trace de pile. – CommonsWare
Mise à jour Code et méthode générant l'erreur –