phonegap: open external page and then go back to app

前端 未结 3 895
感情败类
感情败类 2021-02-09 11:25

ok, browsing the questions I\'ve found the right way to load an external page into the phonegap view (i.e. without loosing the session or opening the device browser) as explaine

3条回答
  •  不思量自难忘°
    2021-02-09 11:55

    This is using PhoneGap/Cordova 2.7. Inside your external app, add a link that points to "app://index".

    Inside onCreate add:

    this.appView.setWebViewClient(new CordovaWebViewClient(this, this.appView) {
    
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if(url.equalsIgnoreCase("app://index")) {
                Log.d("DEBUG", url);
    
                loadUrl(Config.getStartUrl());
    
                return true;
            } else {
                return super.shouldOverrideUrlLoading(view, url);
            }
        }
    });
    

    This will intercept the call and redirect the user to the configured start url.

提交回复
热议问题