3

I have a android app that has built using ionic and i have used xwalk web-view in it. I need to catch page finished loading event inside my MainActivity.java which extends the CordovaActivity class and then perform some action. How i can do this.

LF00
  • 27,015
  • 29
  • 156
  • 295
HarshaXsoad
  • 776
  • 9
  • 30

3 Answers3

5

If you are using xwalkview in Crosswalk Embedded Mode, its API XWalkResourceClient#onLoadFinished can be useful to you. The detail is here API_docs, you can use like this:

class ResourceClient extends XWalkResourceClient {

    public ResourceClient(XWalkView xwalkView) {
        super(xwalkView);
    }

    public void onLoadStarted(XWalkView view, String url) {
        super.onLoadStarted(view, url);
        Log.d(TAG, "Load Started:" + url);
    }

    public void onLoadFinished(XWalkView view, String url) {
        super.onLoadFinished(view, url);
        Log.d(TAG, "Load Finished:" + url);
    }

    public void onProgressChanged(XWalkView view, int progressInPercent) {
        super.onProgressChanged(view, progressInPercent);
        Log.d(TAG, "Loading Progress:" + progressInPercent);
    }
}

mXWalkView.setResourceClient(new ResourceClient(mXWalkView));
mXWalkView.load("http://www.google.com/", null);
  • Thanks but i found the place where "XWalkCordovaResourceClient" class is located (CURRENT_DIR/platforms/android/src/org/crosswalk/engine/) and i did change the "onLoadFinished" method there. May not be a best practice but it did the job :). Although if your solution is also working i'll accept it as a correct answer so as soon as i try your solution and confirm it. Thanks – HarshaXsoad Mar 21 '16 at 07:56
0

If you are using android WebView, please check out the onPageFinished() method.

http://developer.android.com/reference/android/webkit/WebViewClient.html#onPageFinished(android.webkit.WebView, java.lang.String)

whoami
  • 1,517
  • 1
  • 21
  • 29
0

the process event quite similar to Android Webview try this

xWalkView.setResourceClient(new XWalkResourceClient(xWalkView) {
     @Override
      public void onLoadFinished(XWalkView view, String url) {
           super.onLoadFinished(view, url);
           // Stop your loading dialog here
      }
 });

take care

Somwang Souksavatd
  • 4,947
  • 32
  • 30