if you want to reuse an event like in the example the GotUri event (once called from method OpenDocument Tree and again from method OpenSingleDocument) you have 2 options
you can drag the extension twice into the working area and use the blocks like shown in the screenshot, or
use a global variable together with an if statement in the GotUri event like this
if global variable = task1
then do what you want to do for task1
else do what you want to do for task2
Your app works well in my phone, I copied your text files into / Documents, I was able to list / read / delete them, but I'm not able to create my app using your blocks. I don't want list the folder, I want open a single document, read it and save changes.
yes, the app is for my own use, I'm not a developer, I know the file exists because I put it in my phone. I tried reading the file using the uristring, but I think there is a permissions problem
@vknow360 The function "Writes to given uri" apparently no longer works in the beta version of your extension. The doc is created, but nothing is written in it: "No content provider: ...". This worked before as I showed in a video.
Java
@SimpleFunction(description = "Writes to given uri")
public void WriteToFile(final String uriString, final String content) {
AsynchUtil.runAsynchronously(new Runnable() {
@Override
public void run() {
if (!GetMimeType(uriString).equals(DocumentDirMimeType())) {
String res;
try {
OutputStream fileOutputStream = contentResolver.openOutputStream(Uri.parse(uriString));
res = writeToOutputStream(fileOutputStream, content);
res = res.isEmpty() ? uriString : res;
} catch (Exception e) {
res = e.getMessage();
}
postWriteResult(res);
} else {
postError("WriteToFile", "Can't write text to dir");
}
}
});
}
private String writeToOutputStream(OutputStream fileOutputStream, String content) {
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(fileOutputStream);
writer.write(content);
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
} finally {
try {
if (writer != null) {
writer.flush();
writer.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return "";
}