I'm trying to return a function through JavascriptInterface but am getting an error:
Cannot refer to a non-final variable funct inside an inner class defined in a different method
here is the code:
public void androidFieldPrompt(String title, String msg, String funct) {
final EditText input = new EditText(MainActivity.this);
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
alert.setTitle(title);
alert.setMessage(msg);
alert.setView(input);
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
webView.loadUrl("javascript:window."+funct+"('"+value+"')");
return;
}
});
alert.setNegativeButton("CANCEL", null);
alert.show();
}