Android WebView : Why I can not able to redirect t

2019-08-14 18:59发布

问题:

I am trying to pass url to webview that should redirect to play store but Its not working.

What I tried :

String url = "https://play.google.com/store/apps/details?id=com.matchify";
webView.loadUrl(url);

but its loading only inside the webview, how can I solve this?

Thanks in advance

回答1:

To open your app's / any other app's page on play store app use :

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackName)));

Where appPackName is:

 String appPackName = getPackageName();

Play Store app has Intent Filter that will listen to the intent and launch the uri (since it is starting with market:// it will open Play Store. ) If you want to open in browser use uri argument :

https://play.google.com/store/apps/details?id=" + appPackName

Helpful link : How to open the Google Play Store directly from my Android application?