Main アクティビティから URL を読み込んでいます。
super.loadUrl("file:///android_asset/www/index.html");
Web でいくつかのアクティビティを実行した後、イベントで、droidgap を使用して別のアクティビティを呼び出します。
アクティビティの終了時に Web ページに制御を戻すことができません。基本的に、Androidアクティビティに任せた復元/ Webページメカニズムが必要です。
以下は、JS へのアクセスを提供する MyClass(DroidGap) の一部のスニペットです。
public class MyClass extends DroidGap{
static WebView mAppView;
static DroidGap mGap;
private String RInfo[] = new String[5];
public MyClass(DroidGap gap, WebView view)
{
mAppView = view;
mGap = gap;
}
public void initiateDP(){
Intent intent = new Intent(mGap, DPActivity.class);
mGap.startActivity(intent);
}
主な活動 :-
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
super.setIntegerProperty("loadUrlTimeoutValue", 40000);
mc = new MyClass(this, appView);
appView.addJavascriptInterface(mc, "MyCls");
super.loadUrl("file:///android_asset/www/index.html");
}
Index.html:-
alert('shaken');
var r = window.confirm('Do you want to enable remote');
if(r == true)
{
// alert('before redirecting');
window.MyCls.initiateDP();
}
これにより、DPActivity が開始されます。そのため、DPActivity から、離れたページに戻る必要があります。DPActivity で:-
if(MyClass.mAppView.canGoBack()) {
MyClass.mAppView.goBack();
}
else{
finish();
}
これは起こっていません。他のメカニズムを提案するか、間違っている場合は修正してください。