[android-developers] Re: Handling Redirects in Android WebView
*It is 2018 now, but if someone still got the problem like this, I've found a dicision.You can listen for URL redirects in method shouldOverrideUrlLoading(...) it's still true, but ALL redirects webview recognizes as clicks inside web page, as Mark Murphy mentioned before.To prevent this (not an idial variant, but it works) you can listen touch event on your webview,something like this:* @Override public boolean onTouch(View v, MotionEvent event) { if (v.getId() == R.id.web_view && event.getAction() == MotionEvent.ACTION_DOWN) { isTouched = true; } return false; } *Finally, when user will click on the webpage link, you will have this * *isTouched* *variable. You can now use it in method like this: * @Override public boolean shouldOverrideUrlLoading(WebView view, String urltoGo) { if (isTouched) return true; /*really clicked link*/ else return false; /*just redirect*/ } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/d547834e-e141-4c44-b499-30a3922510a2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: Handling Redirects in Android WebView
*It is 2018 now, but if someone still got the problem like this, I've fount a dicision.You can listen for URL redirects in method shouldOverrideUrlLoading(...) it's still true, but ALL redirects webview recognizes as clicks inside web page, as Mark Murphy mentioned before.To prevent this (not an idial variant, but it works) you can listen touch event on your webview,something like this:* @Override public boolean onTouch(View v, MotionEvent event) { if (v.getId() == R.id.web_view && event.getAction() == MotionEvent.ACTION_DOWN) { isTouched = true; } return false; } *Finally, when user will click on the webpage link, you will have this * *isTouched* *variable. You can now use it in method like this: * @Override public boolean shouldOverrideUrlLoading(WebView view, String urltoGo) { if (isTouched) return true; /*really clicked link*/ else return false; /*just redirect*/ } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/fbf91315-462a-4055-a550-50d151a32beb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.