I have some links in my webview that are market: // links. When my users click on them, this leads to the fact that the page cannot be found.
How can I resolve all links that start from the market: // automatically open the Google Play store when they are used? I tried:
final Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(Uri.parse("market://details?id=")); startActivity(intent); }
but it seemed to do nothing. I am new to this, so any help would be greatly appreciated. Also, FYI, I cannot change the market: // links to play.google.com myself. They belong to my advertiser.
Anyway, I can include it in this code:
public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString) { if (DEBUG) Log.e("shouldOverride", paramString); if (Uri.parse(paramString).getHost()!=null && (!Uri.parse(paramString).getHost().equals("market.android.com")) && (!paramString.contains("facebook.com")) && (!Uri.parse(paramString).getHost().contains("twitter.com")) && (!Uri.parse(paramString).getHost().equals("play.google.com")) && (!Uri.parse(paramString).getHost().contains("bit.ly")) && (!Uri.parse(paramString).getHost().contains("plus.google.com")) && (!Uri.parse(paramString).getHost().contains("youtube.com"))){ if(isAppOrGamePage(paramString)){ final Intent intent = new Intent(MainActivity.this, PageActivity.class); intent.putExtra("app_url", paramString); startActivity(intent); } else return false; } else { final Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(paramString)); startActivity(intent); } return true; } }
source share