| | |
| | | request.setDescription(desc); |
| | | // 完成后显示通知栏 |
| | | request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); |
| | | request.setDestinationInExternalFilesDir(weakReference.get(), Environment.DIRECTORY_DOWNLOADS, HdlAppUpdateLogic.ApkFileName); |
| | | request.setDestinationInExternalFilesDir(weakReference.get(), Environment.DIRECTORY_DOWNLOADS, HdlAppUpdateLogic.getInstance().getApkFileName()); |
| | | request.setMimeType("application/vnd.android.package-archive"); |
| | | } else { |
| | | request.setDestinationInExternalFilesDir(weakReference.get(), Environment.DIRECTORY_DOWNLOADS, HDLUniMP.UNI_APP_ID + ".wgt"); |
| | |
| | | @Override |
| | | public void run() { |
| | | AndroidPermissionActivity.sListener = listener; |
| | | Intent intent1 = new Intent(context, AndroidPermissionActivity.class); |
| | | intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | context.startActivity(intent1); |
| | | Intent intentPermission = new Intent(context, AndroidPermissionActivity.class); |
| | | intentPermission.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | context.startActivity(intentPermission); |
| | | } |
| | | }, 2000); |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * @param context |
| | | * @param intent |
| | | * @param context - |
| | | * @param intent - |
| | | */ |
| | | private void installApk(Context context, Intent intent) { |
| | | long completeDownLoadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1); |
| | |
| | | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { // 6.0以下 |
| | | uri = mDownloadManager.getUriForDownloadedFile(completeDownLoadId); |
| | | if (null == uri) { |
| | | File apkFile = new File(weakReference.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.ApkFileName); |
| | | File apkFile = new File(weakReference.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.getInstance().getApkFileName()); |
| | | if (apkFile.exists()) { |
| | | uri = Uri.fromFile(apkFile); |
| | | } |
| | |
| | | } else { // Android 7.0 以上 |
| | | uri = FileProvider.getUriForFile(context, |
| | | "com.hdl.debugtreasure.dc.fileprovider", |
| | | new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.ApkFileName)); |
| | | new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.getInstance().getApkFileName())); |
| | | intentInstall.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
| | | } |
| | | // 安装应用 |