Android- Webview onPageFinished Called Twice

后端 未结 7 985
名媛妹妹
名媛妹妹 2020-12-05 14:08

I have an activity that does OAuth authentication by intercepting the redirect url once it show up in the webview. However, the onPageFinished function is somehow called twi

7条回答
  •  执笔经年
    2020-12-05 14:40

    Since onPageFinished is being called more than once, you can simply check if the method is already called before executing anything further.

    @Override
    public void onPageFinished(WebView view, String url) {
         if (loaded) {
              return;
         }
    
         // Do something...
    
         loaded = true;
    }
    

提交回复
热议问题