I am trying to implement an error screen when a certain event is triggered in my js code. Since the error page is local, my attempt to set window.location.href = 'file:///android_assets/www/error.html' throws an error indicating cannot load local resource.
So I am trying to create a plugin in android and doing the following:
public PluginResult execute(final String action, final JSONArray data, final String callBackId) {
// final DroidGap currentCtx = (DroidGap) ctx.getContext();
final Context currentCtx = cordova.getActivity();
MainActivity ma = (MainActivity) currentCtx;
ma.loadUrl("file:///android_assets/www/error.html");
PluginResult result = null;
return result;
}
The problem is this code doesn’t load the URL. I am not sure if this is the right way of calling. Any insights please?
I see an error like:
08-16 01:08:48.974: I/Web Console(730): JSCallback Error: Request failed. at file:///android_asset/www/cordova-2.0.0.js:3698
It works for me when I add a public loadUrl in the MainActivity
….
I’m using PhoneGap 1.8.1 but I don’t think it matter in this case.