From 48886374d561b8b39d38cac505f423aa260c495e Mon Sep 17 00:00:00 2001 From: hch <16607480311@163.com> Date: Thu, 7 Dec 2023 17:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=94=AF=E4=BB=98=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/main/activity/GoogleFragment.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java index b368c8dad..9b03293ea 100644 --- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java @@ -17,6 +17,8 @@ import android.webkit.WebView; import androidx.fragment.app.Fragment; import com.facebook.appevents.AppEventsConstants; +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.GoogleApiAvailability; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.utils.GoogleUtils; @@ -40,6 +42,8 @@ public class GoogleFragment extends Fragment { GoogleUtils googleUtils; + boolean isGoogleService = true; + public GoogleFragment() { } @@ -59,13 +63,20 @@ public class GoogleFragment extends Fragment { rlWebview = (WebView) view.findViewById(R.id.rlWebview); Log.e("ttt", url); rlWebview.loadUrl(url); - initGooglePay(); - new Thread() { - @Override - public void run() { - adid = googleUtils.getAdid(); - } - }.start(); + + // 验证是否已在此设备上安装并启用Google Play服务,以及此设备上安装的旧版本是否为此客户端所需的版本 + int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getActivity()); + if (code == ConnectionResult.SUCCESS) { + isGoogleService = true; + // 支持Google服务 + initGooglePay(); + new Thread() { + @Override + public void run() { + adid = googleUtils.getAdid(); + } + }.start(); + } WebSettings webSettings = rlWebview.getSettings(); webSettings.setDomStorageEnabled(true);