Android Question Webview and redirects

adriano.freitas

Active Member
I have been using webview and it has worked perfectly for what I need, however, now I need it to open links from two platforms and they do not work (I need to open these links without using an external browser). I think it's because they use redirects.

URL examples:



and


https://music.amazon.com.br/podcast...e45-56c65340ed28/episodes/f138808d-a044-44a4- 94e7-a2c7e75ca245/neuroci%C3%AAncias-por-adriano-freitas-uff-0265---o-c%C3%A9rebro-e-suas-ilus%C3%B5es


Does anyone know of a solution to open these links without using an external browser?


Thanks!
 

adriano.freitas

Active Member
What happens when you try to open them?

You can get more information about errors with: https://www.b4x.com/android/forum/threads/problem-with-webview-javascript.165062/#post-1012042
Links like these use redirects. When they are accessed, the URL changes, being handled either by an app of platform if it is installed or by the platform's website. It seems to me that he's not dealing with it well and when he switches to an intent or something similar, he doesn't do anything.

The result is an empty webview, with nothing in it.
 
Upvote 0

adriano.freitas

Active Member
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the site can recognize an android webview (you might want to try changing the user-agent). when this occurs, it redirects the user to a url whose scheme is "intent://". this is meant to launch the appropriate app on the user's device. you can possibly work around this by intercepting webview client's shouldOverrideUrlLoading method.
obviously you could change the scheme to https://, but that doesn't necessarily mean you're going to get a webpage as a result. by using "intent" deep-linking, the site wants to launch an app, not serve a webpage. by changing the user agent, you might get a few steps further, but the site is expecting you to have that app. if you use shouldOverrideUrlLoading, you would return true (to abort the loading) and then launch the app. when the site detects a desktop browser, it just does a normal redirect.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…