I’ve updated my code to look like this :-
import android.widget.Toast;
import android.webkit.JavascriptInterface;
import android.content.res.AssetManager;
import android.webkit.WebViewClient;
import android.os.Looper;
import android.content.Context;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.view.ViewGroup;
import android.app.Activity;
import android.widget.RelativeLayout;
import android.widget.FrameLayout;
import java.io.File;
import android.os.Bundle;
import android.os.Environment;
FrameLayout fl;
Activity act;
WebView web;
Context context;
WebViewClient wbc;///if you want to use chrome
File[] files;//if you want to list files
String[] filesPath;//if you want to list subfolders
public class JavaScriptInterface {
Context mContext;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
@JavascriptInterface
public void showToast(String toast) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
}
}
void settings(){
fullScreen();
};
public void onStart() {
super.onStart();
act = this.getActivity();
wbc = new WebViewClient();
web = new WebView(act);
web.setLayoutParams(new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT));
web.setWebViewClient(wbc);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("file:///android_asset/index.html");
fl = (FrameLayout)act.getWindow().getDecorView().getRootView();
fl.addView(web);
web.addJavascriptInterface(new JavaScriptInterface(this), "Android");
};
void setup(){
background(255,0,0);
};
void draw(){
background(255,0,0);
};
on the last line in onStart()
it shows error;; i dont undersatnd why??