Skip to content

Commit 77ad79b

Browse files
committed
修复不能自动跳转安装的问题
1 parent b471269 commit 77ad79b

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ allprojects {
4141
}
4242

4343
ext {
44-
update_app_version = '3.5.1'
45-
update_app_kotlin_version = '1.2.2'
44+
update_app_version = '3.5.2'
45+
update_app_kotlin_version = '1.2.3'
4646
}
4747

4848

json/json.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"apk_file_url": "https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/apk/sample-debug.apk",
55
"update_log": "1,添加删除信用卡接口。\r\n2,添加vip认证。\r\n3,区分自定义消费,一个小时不限制。\r\n4,添加放弃任务接口,小时内不生成。\r\n5,消费任务手动生成。",
66
"target_size": "5M",
7-
"new_md5":"60e2c3ab8bb4c078438f654e39c7b6a0",
7+
"new_md5":"b97bea014531123f94c3ba7b7afbaad2",
88
"constraint": false
99
}

json/json1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"apk_file_url": "https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/apk/sample-debug.apk",
55
"update_log": "1,添加删除信用卡接口。\r\n2,添加vip认证。\r\n3,区分自定义消费,一个小时不限制。\r\n4,添加放弃任务接口,小时内不生成。\r\n5,消费任务手动生成。",
66
"target_size": "5M",
7-
"new_md5":"60e2c3ab8bb4c078438f654e39c7b6a0",
7+
"new_md5":"b97bea014531123f94c3ba7b7afbaad2",
88
"constraint": true
99
}

sample/src/main/java/com/vector/appupdatedemo/ui/JavaActivity.java

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ public void updateApp(View view) {
8686
.setActivity(this)
8787
//更新地址
8888
.setUpdateUrl(mUpdateUrl)
89+
.handleException(new ExceptionHandler() {
90+
@Override
91+
public void onException(Exception e) {
92+
e.printStackTrace();
93+
}
94+
})
8995
//实现httpManager接口的对象
9096
.setHttpManager(new UpdateAppHttpUtil())
9197
.build()

update-app/src/main/java/com/vector/update_app/UpdateDialogFragment.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.vector.update_app;
22

33
import android.Manifest;
4+
import android.app.Activity;
45
import android.content.ComponentName;
56
import android.content.DialogInterface;
67
import android.content.Intent;
@@ -76,6 +77,7 @@ public void onServiceDisconnected(ComponentName name) {
7677
private TextView mIgnore;
7778
private IUpdateDialogFragmentListener mUpdateDialogFragmentListener;
7879
private DownloadService.DownloadBinder mDownloadBinder;
80+
private Activity mActivity;
7981

8082
public UpdateDialogFragment setUpdateDialogFragmentListener(IUpdateDialogFragmentListener updateDialogFragmentListener) {
8183
this.mUpdateDialogFragmentListener = updateDialogFragmentListener;
@@ -99,6 +101,10 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
99101
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.UpdateAppDialog);
100102

101103

104+
mActivity = getActivity();
105+
106+
107+
102108
}
103109

104110
@Override
@@ -418,12 +424,15 @@ public void onError(String msg) {
418424

419425
@Override
420426
public boolean onInstallAppAndAppOnForeground(File file) {
421-
// 如果应用处于前台,那么就自行处理应用安装
422-
AppUpdateUtils.installApp(UpdateDialogFragment.this.getActivity(), file);
423427
if (!mUpdateApp.isConstraint()) {
424428
dismiss();
425429
}
426-
return true;
430+
if (mActivity != null) {
431+
AppUpdateUtils.installApp(mActivity, file);
432+
return true;
433+
} else {
434+
return false;
435+
}
427436
}
428437
});
429438
}

0 commit comments

Comments
 (0)