Javascript 如何将链接重定向到Google Play Market?
我已经使用WebView应用程序创建了一个应用程序,它显示了我博客的网站,我在你的博客中使用Google Play的链接,但我无法使Google Play的所有链接都在Play市场上打开,现在应用程序中打开的所有链接甚至都没有转发到浏览器。我应该使用什么代码来执行此操作?请帮忙 以下是我在MainActivity.java中使用的代码:Javascript 如何将链接重定向到Google Play Market?,javascript,android,redirect,webview,webviewclient,Javascript,Android,Redirect,Webview,Webviewclient,我已经使用WebView应用程序创建了一个应用程序,它显示了我博客的网站,我在你的博客中使用Google Play的链接,但我无法使Google Play的所有链接都在Play市场上打开,现在应用程序中打开的所有链接甚至都没有转发到浏览器。我应该使用什么代码来执行此操作?请帮忙 以下是我在MainActivity.java中使用的代码: package com.thegosa.bterwe; 导入android.annotation.TargetApi; 导入android.app.Activ
package com.thegosa.bterwe;
导入android.annotation.TargetApi;
导入android.app.Activity;
导入android.app.FragmentManager;
导入android.content.Intent;
导入android.net.Uri;
导入android.os.Build;
导入android.support.v7.app.ActionBarDrawerToggle;
导入android.support.v7.app.AppActivity;
导入android.os.Bundle;
导入android.support.v7.graphics.drawable.drawerRowDrawable;
导入android.util.Log;
导入android.view.view;
导入android.webkit.WebChromeClient;
导入android.webkit.WebResourceRequest;
导入android.webkit.WebSettings;
导入android.webkit.WebView;//导入WebView类
导入android.webkit.WebViewClient;//导入类WebViewClient
导入android.widget.ProgressBar;
导入android.widget.Toast;
@抑制警告(“全部”)
公共类MainActivity扩展了AppCompatActivity{
网络视图;
私有Bundle savedInstanceState;
//当按下Back时,返回。
@凌驾
public void onBackPressed(){
if(wv.canGoBack()){
wv.goBack();
}否则{
super.onBackPressed();
}
}
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv=(WebView)findviewbyd(R.id.WebView);
//启用JavaScript
wv.getSettings().setJavaScriptEnabled(true);
wv.setFocusable(真);
wv.setFocusableInTouchMode(真);
//将“渲染优先级”设置为“高”
wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
wv.getSettings().setCacheMode(WebSettings.LOAD_NO_缓存);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setDatabaseEnabled(true);
wv.getSettings().setAppCacheEnabled(true);
wv.setScrollBarStyle(视图。滚动条在覆盖层内);
//加载Url
wv.loadUrl(“http://themesxperia.blogspot.com/");
setWebViewClient(新的WebViewClient());
}
}
你应该使用谷歌游戏市场的意向,而不是网络视图
以下是解决方案:
你应该使用谷歌游戏市场的意图,而不是网络视图 以下是解决方案: 这将打开游戏市场,如果不可能,它将打开您应用程序网站上的浏览器 其中字符串为: 我们的评级为“market://details?id=com.companyname.appname“ rate_us2是连接到Play Store中您的应用程序的链接 希望能有帮助 这将打开游戏市场,如果不可能,它将打开您应用程序网站上的浏览器 其中字符串为: 我们的评级为“market://details?id=com.companyname.appname“ rate_us2是连接到Play Store中您的应用程序的链接
希望有帮助。应该会有帮助:>尝试在wv.setWebViewClient(new WebViewClient())中注释这一行;并从应用程序管理器中清除此程序包的首选项。这应该会有所帮助:>请尝试注释这一行wv.setWebViewClient(new WebViewClient());并从application manager中清除此包的首选项。
public void OpenPlayStore() {
Uri uri = Uri.parse(getResources().getString(R.string.rate_us));
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(getResources().getString(R.string.rate_us2))));
}
}