新增判断 判断是否有google服务
This commit is contained in:
parent
d0b7b065b2
commit
f8ac4617ed
@ -174,6 +174,19 @@ public class GoogleUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getGoogleService() {
|
||||
boolean flag;
|
||||
try {
|
||||
Class<?> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_google.utils.GoogleBillingManage");
|
||||
googlePay = clz.getConstructor(Activity.class).newInstance(mActivity);
|
||||
flag = (boolean) googlePay.getClass().getMethod("getGoogleService").invoke(googlePay);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
public void setFirebaseTokenListener(Activity activity, FirebaseTokenListener firebaseTokenListener) {
|
||||
Timer timer = new Timer();
|
||||
TimerTask task = new TimerTask() {
|
||||
|
@ -20,6 +20,7 @@ import com.android.billingclient.api.SkuDetails;
|
||||
import com.android.billingclient.api.SkuDetailsParams;
|
||||
import com.android.billingclient.api.SkuDetailsResponseListener;
|
||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
|
||||
import com.google.android.gms.common.GooglePlayServicesRepairableException;
|
||||
|
||||
@ -28,11 +29,8 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 新写Google内付工具类做简单的封装
|
||||
@ -201,6 +199,11 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getGoogleService() {
|
||||
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(mContext);
|
||||
return code == 0;
|
||||
}
|
||||
|
||||
int resultCode = -1;
|
||||
String resultToken = "";
|
||||
String resultOrderId = "";
|
||||
|
@ -17,8 +17,6 @@ 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;
|
||||
@ -47,7 +45,6 @@ public class GoogleFragment extends Fragment {
|
||||
public GoogleFragment() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
@ -64,9 +61,10 @@ public class GoogleFragment extends Fragment {
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
|
||||
googleUtils = new GoogleUtils(getActivity());
|
||||
|
||||
// 验证是否已在此设备上安装并启用Google Play服务,以及此设备上安装的旧版本是否为此客户端所需的版本
|
||||
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getActivity());
|
||||
if (code == ConnectionResult.SUCCESS) {
|
||||
if (googleUtils.getGoogleService()) {
|
||||
isGoogleService = true;
|
||||
// 支持Google服务
|
||||
initGooglePay();
|
||||
|
Loading…
Reference in New Issue
Block a user