v418
This commit is contained in:
@@ -91,8 +91,9 @@ public class UpdateService extends Service {
|
||||
|
||||
this.updateNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
updateIntent = new Intent(this, SettingVersionActivity.class);
|
||||
updatePendingIntent = PendingIntent.getActivity(this, 0, updateIntent, 0);
|
||||
updateIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);//关键的一步,设置启动模式
|
||||
updateIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);//关键的一步,设置启动模式
|
||||
// Android 12+ 需要显式声明 PendingIntent 的可变性,这里通知点击行为不需要修改,使用 FLAG_IMMUTABLE
|
||||
updatePendingIntent = PendingIntent.getActivity(this, 0, updateIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||
notificationUtils = new NotificationUtils(this,0,updatePendingIntent);
|
||||
notificationUtils.sendUpVersonNotification("开始下载", "当前下载进度:0%");
|
||||
|
||||
@@ -128,7 +129,8 @@ public class UpdateService extends Service {
|
||||
intent.setDataAndType(FileProvider.getUriForFile(UpdateService.this, "cn.shangyu.gdxzExpert.fileprovider", updateFile),"application/vnd.android.package-archive");
|
||||
getApplicationContext().startActivity(intent);
|
||||
// startActivity(intent);
|
||||
updatePendingIntent = PendingIntent.getActivity(UpdateService.this, 0, intent, 0);
|
||||
// 安装 APK 的 PendingIntent 同样不需要在外部被修改,使用 FLAG_IMMUTABLE
|
||||
updatePendingIntent = PendingIntent.getActivity(UpdateService.this, 0, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
NotificationUtils notificationUtils1 = new NotificationUtils(UpdateService.this,0,updatePendingIntent);
|
||||
notificationUtils1.sendUpVersonNotification("肝胆相照专家版", "下载完成,点击安装");
|
||||
|
||||
Reference in New Issue
Block a user