Search code examples
paypalwebviewpaymentsubscriptionbraintree

Paypal page not loading in Android app, just shows spinner, until I touch screen 6.0.1


I am using Braintree for subscriptions, in my Android app. I access a page in a webview. From this page, I select the paypal payment type and then press next. I get the paypal spinner, which means it's loading. and only that. If I don't swipe my finger on the screen, or press the home button and come back, it won't reload, and be stuck at the spinner. The moment I do one of those things it dismisses the spinner and shows the "Mock Sandbox Purchase Flow". This is the only thing I get in the logs:

01-15 10:31:36.482: W/cr.BindingManager(10025): Cannot call determinedVisibility() - never saw a connection for the pid: 10025

Any Ideea what is wrong here? This is how I initiate my Webview, if it helps:

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            WebView.setWebContentsDebuggingEnabled(true);
        }  
  wv.setWebChromeClient(new WebChromeClient());
        wv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        WebSettings settings = wv.getSettings();
        settings.setAllowUniversalAccessFromFileURLs(true);
        settings.setJavaScriptEnabled(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        settings.setAppCacheEnabled(false);
        settings.setDomStorageEnabled(true);
        wv.setWebViewClient(new WebViewClient());
 file = "http://192.168.1.24:9000/" + lang + "/dashboard/billing?key="+Uri.encode(token)+"&id=" + PSLocationCenter.getInstance().pref.getUserId(PSWebViewActivity.this);
    wv.loadUrl(file);

This happens on a Nexus 5 with Android 6.0.1. This works on a LG G3 with 5 and a Galaxy Note 2 with 4.4.2


Solution

  • Fixed this with a small hack that will simulate a motion event, in order to refresh the webview. But if somebody has a more classy solution for this, I am open to sugestions. MY fix:

     private void simulate(){
        Handler han = new Handler();
        han.postDelayed(new Runnable() {
            @Override
            public void run() {
                if(wv != null) {
                    MotionEvent motionEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis() + 10, MotionEvent.ACTION_DOWN, 0, 0, 0);
                    wv.dispatchTouchEvent(motionEvent);
                    simulate();
                }
            }
        }, 5000);
    }