This commit is contained in:
hch
2023-12-19 18:29:48 +08:00
parent 9d543f2211
commit f697e650a8
14 changed files with 66 additions and 33 deletions

View File

@@ -6,6 +6,7 @@ import android.content.Intent;
import com.alibaba.fastjson.JSON;
import com.yunbao.common.R;
import org.json.JSONObject;
@@ -162,10 +163,10 @@ public class GoogleUtils {
billingListener.onPaySuccess(token, orderId);
} else if (code == 1) {
timer.cancel();
billingListener.onPayFailed("支付取消");
billingListener.onPayFailed(mActivity.getString(R.string.pay_cancel));
} else if (code == 2) {
timer.cancel();
billingListener.onPayFailed("支付失败");
billingListener.onPayFailed(mActivity.getString(R.string.pay_fail));
}
} catch (Exception e) {
throw new RuntimeException(e);
@@ -185,19 +186,6 @@ 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() {

View File

@@ -114,8 +114,10 @@ public class APKUpdateCustomPopup extends CenterPopupView {
mContext.finish();
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
//华为
//todo
launchAppDetail(mContext, "com.pdlive.shayu", "com.huawei.appmarket");
launchHwAppDetail(mContext, "com.pdlive.shayu", "com.huawei.appmarket");
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
//三星
launchSmAppDetail(mContext, "com.pdlive.shayu", "com.sec.android.app.samsungapps");
} else {
versionImmediateUse.setVisibility(GONE);
updateLine.setVisibility(VISIBLE);
@@ -130,23 +132,41 @@ public class APKUpdateCustomPopup extends CenterPopupView {
});
}
public static boolean isAppStoreExist(Context context) {
public static void launchSmAppDetail(Context mContext, String appPkg, String marketPkg) {
try {
if (TextUtils.isEmpty(appPkg)) {
return;
}
if (isAppStoreExist(mContext, marketPkg)) {
Uri uri = Uri.parse("market://details?id=" + appPkg);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (!TextUtils.isEmpty(marketPkg)) {
intent.setPackage(marketPkg);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static boolean isAppStoreExist(Context context, String marketPkg) {
try {
PackageManager packageManager = context.getPackageManager();
packageManager.getPackageInfo("com.huawei.appmarket", PackageManager.GET_ACTIVITIES);
packageManager.getPackageInfo(marketPkg, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public static void launchAppDetail(Context mContext, String appPkg, String marketPkg) {
public static void launchHwAppDetail(Context mContext, String appPkg, String marketPkg) {
try {
if (TextUtils.isEmpty(appPkg)) {
return;
}
if (isAppStoreExist(mContext)) {
if (isAppStoreExist(mContext, marketPkg)) {
Uri uri = Uri.parse("appmarket://details?id=" + appPkg);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (!TextUtils.isEmpty(marketPkg)) {