测试app内下载安装
This commit is contained in:
@@ -74,7 +74,7 @@ public class AppUpdateDialog extends BaseDialog<DialogAppUpdateBinding> implemen
|
||||
mProgressDialog.setCanceledOnTouchOutside(false);
|
||||
mProgressDialog.setMessage("下载中请稍等!!!");
|
||||
mProgressDialog.show();
|
||||
DownloadUtil downloadUtil = new DownloadUtil(getContext());
|
||||
DownloadUtil downloadUtil = new DownloadUtil(getContext(),appUpdateModel.getUrl());
|
||||
downloadUtil.downloadFile(appUpdateModel.getUrl(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
@@ -41,14 +42,17 @@ public class DownloadUtil {
|
||||
private static final String PATH_AUDIO = Environment.getExternalStorageDirectory() + "/qipao/audio";
|
||||
|
||||
|
||||
public DownloadUtil(Context context) {
|
||||
public DownloadUtil(Context context,String downUrl) {
|
||||
this.mContext = context;
|
||||
|
||||
if (mApi == null) {
|
||||
//初始化网络请求接口
|
||||
mApi = ApiHelper.getInstance().createService(ApiInterface.class);
|
||||
mApkPath = new File(mContext.getFilesDir(), PATH_APK).getAbsolutePath();
|
||||
|
||||
int i = downUrl.lastIndexOf('/');//一定是找最后一个'/'出现的位置
|
||||
if (i != -1) {
|
||||
downUrl = downUrl.substring(i);
|
||||
}
|
||||
mApkPath = new File(Objects.requireNonNull(mContext.getExternalFilesDir(PATH_APK+"_"+downUrl)).getAbsolutePath()).getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user