feat:完成mycard跳转对接

This commit is contained in:
Max
2024-01-31 11:42:09 +08:00
parent 03faea9138
commit 4475d622fd

View File

@@ -54,6 +54,7 @@ import com.yizhuan.xchat_android_core.web.bean.WebJsBeanInfo;
import com.yizhuan.xchat_android_core.web.event.WebViewRefreshEvent;
import com.yizhuan.xchat_android_library.rxbus.RxBus;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -195,6 +196,7 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
@SuppressLint("SetJavaScriptEnabled")
private void initData() {
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
@@ -210,14 +212,13 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
webView.addJavascriptInterface(jsInterface, "androidJsObj");
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setWebViewClient(new WebViewClient() {
String packageName;
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Logger.e("shouldOverrideUrlLoading--------" + url);
LogUtil.e("shouldOverrideUrlLoading" + url);
targetUrl = url;
if (url.contains("tel:")) {
//删除直接拨打电话的功能
return true;
@@ -225,6 +226,7 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
// ------- 处理结束 -------
if (!(url.startsWith("http") || url.startsWith("https"))) {
handleIntent(url);
return true;
}
@@ -268,6 +270,42 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
super.onPageStarted(view, url, favicon);
mProgressBar.setVisibility(View.VISIBLE);
}
private void handleIntent(String url) {
Intent intent;
try {
if (url.startsWith("intent://")) {
//MyCard、Line
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
packageName = intent.getPackage();
} else { //第三方支付
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
}
startActivity(intent);
} catch (Exception e) {
handleCatch(e);
}
}
private void handleCatch(Exception ex) {
if (packageName != null) {
toGooglePaly(packageName);
} else {
SingleToastUtil.showToast(ex.getMessage());
}
}
private void toGooglePaly(String packageName) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)));
} catch (android.content.ActivityNotFoundException anfe) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName)));
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
//获取webviewtitle作为titlebar的title
wvcc = new WebChromeClient() {