Przeglądaj źródła

apk util check install status

billyyoyo 5 lat temu
rodzic
commit
a1ccf2e26b

+ 5 - 1
app/src/main/java/com/kfzs/duanduan/utils/ApkUtils.java

@@ -20,6 +20,7 @@ import com.sheep.gamegroup.model.entity.ApkFileInfo;
 import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.util.DataKey;
 import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -113,6 +114,7 @@ public class ApkUtils {
                     @Override
                     public void onComplete() {
                         hideProgress();
+                        LogUtil.logI("ApkInstall: oncomplete " + doneNext);
                         if (doneNext)
                             return;
                         if (apkFileInfo.isAppInstalled()) {//在onNext中未处理且应用已经安装的情况下,直接打开应用
@@ -124,6 +126,7 @@ public class ApkUtils {
 
                     @Override
                     public void onError(Throwable e) {
+                        LogUtil.logI("ApkInstall: onerror " + doneNext);
                         hideProgress();
                         G.showToast(e.getMessage());
                     }
@@ -131,6 +134,7 @@ public class ApkUtils {
                     @Override
                     public void onNext(final ApkFileInfo item) {
                         doneNext = true;
+                        LogUtil.logI("ApkInstall: onnext " + doneNext);
                         checkAndInstall(item);
                     }
 
@@ -147,7 +151,7 @@ public class ApkUtils {
                                 DataUtil.putAsString(DataKey.KEY_INSTALL_APK_PACKAGE_NAME, item.getPackageName());
                             }
                         } else {//签名不同,则提示卸载
-                            ViewUtil.showMsgDialog(SheepApp.getInstance(), new DialogConfig()
+                            ViewUtil.showMsgDialog(SheepApp.getInstance().getCurrentActivity(), new DialogConfig()
                                     .setTitle("提示").setMsg("需要卸载当前应用才能继续安装,是否继续").setBtnLeftText("不用了")
                                     .setBtnRightText("继续").setBtnRightOnClickListener(view -> {
                                         //这里卸载后 没法继续,需要在接收卸载广播的地方进行安装操作

+ 5 - 0
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -152,6 +152,11 @@ public class KFZSJs {
     }
 
     @JavascriptInterface
+    public void isInstalled(String pkg) {
+        PackageUtil.isAppInstalled(activity, pkg);
+    }
+
+    @JavascriptInterface
     public void gotoLogin() {
         iWeb.clearWebView();
         Jump2View.getInstance().gotoLoginAgain();