Hello, I have try many tutorials/issues whitout succes, but i’have got the same results : java.lang.IllegalArgumentException: File /storage/emulated/0/DCIM/cat.jpg contains a path separator
That has nothing to see with API and this error was solved 20 times on this forum: Environment.getExternalStoragePublicDirectory(…) returns a FILE and a file cannot be called “/dossier1/directory2/subfolder4/monfichier.jpg” but only “monfichier.jpg” !
So, as explained in the other posts, instead of your code you have to write:
@julienrat===
adding permission with the Manifest does not work anymore: you have to ask for permission on run time by code; yet, if you look at your app when it crashes i think that you can see under the crash pop up another one which is “this app is asking permission bla bla”) and (only for testing!) you can (perhaps) acceed to this popup and agree…though it is not at all the good way!
HI,
I am new to developing apps for android phones using processing and am testing the ability to write to, read from external storage like the sd card and came across this post. However the above code with requestPermission(…) method does not seem to work with android phones with versions above android pie (SDK 28), so does not work with SDK 29,30 for example. I get the error:
AndroidDevice: cannot find process id, console output will be disabled.
followed by:
"Read SDcard is not available"
"Write SDcard is not available"
I tried setting android:targetSdkVersion=“28”/> in the andriodManifest.xml file but this had no effect.
I also looked on the android .developer website which seems to indicate that the permissions setting methods for post SDK28 seems to have changed but this just confused me. Is there an updated method for setting permissions to access directories/files etc on external storage using processing?
I have since found that the requestPermission(…) method does seem to work as long as the associated definitely exists in the manifest file as well as being coded. Dont assume that it does even though it has been added in the code. Is this normal behaviour?
I have also found that when the application is first run on a device a popup occurs asking for permission to use the particular feature but after that every time the app is run is doesnt - is this normal behaviour?
public class Permission{
PApplet parent;
String p;
public Permission(PApplet pParent,String permissionName) {
parent = pParent;
p = permissionName;
parent.requestPermission("android.permission."+permissionName, "onPermissionResult", this);
};
public void onPermissionResult(boolean granted) {
if (!granted) {
PApplet.println("User did not grant", p ,"permission.", p ,"is disabled.");
}
};
};
//make sure to check permission in sketch permissions
void setup(){
// change the string value to desired permission
Permission p = new Permission(this, "WRITE_EXTERNAL_STORAGE");
}