It works on Android 11!!! Thank You!!!
1 Like
Remove all your comments, e.g. // play
, from your javascript, then try again.
See
✨ [Free] NoFileHtml - view html without files - #16 by TIMAI2
(I have now updated the first post with this information)
2 Likes
can i have its code
Sure:
package uk.co.metricrat.nofilehtml;
import android.util.*;
import android.webkit.*;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.*;
import java.io.*;
import java.io.File;
import static org.acra.ACRA.LOG_TAG;
public class NoFileHtml extends AndroidNonvisibleComponent {
public NoFileHtml(ComponentContainer container) {
super(container.$form());
}
private String filePath;
@SimpleFunction(description = "presents html text in a webviewer")
public void NoFileHtml(String html, WebViewer webViewer) {
//give webviewer file access for Kodular users
WebView webView = (WebView)webViewer.getView();
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
webView.getSettings().setAllowContentAccess(true);
//create html file
try {
java.io.File file = File.createTempFile("display", ".html");
filePath = file.getAbsolutePath();
FileWriter filewriter = new FileWriter(file);
filewriter.write(html);
filewriter.close();
file.deleteOnExit();
} catch (IOException e) {
Log.e(LOG_TAG, "IOException", e);
}
//show html
webViewer.GoToUrl("file://" + filePath);
}
}
1 Like
It's a Rush project. To compile it from the Niotron IDE you need to add required annotations.
@DesignerComponent
@SimpleObject
oh ok