You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
问题描述
targetSdk > 30时且使用后台更新模式,显示apk下载完成通知时会抛出异常,异常信息如下: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
原因是Android12的新特性,要求应用创建的每个PendingIntent对象都要指定可变性, 使用flag只能为PendingIntent.FLAG_MUTABLE 或PendingIntent.FLAG_IMMUTABLE,而在com.xuexiang.xupdate.service.DownloadService#showDownloadCompleteNotification()在创建PendingIntent时指定的flag是PendingIntent.FLAG_UPDATE_CURRENT。
问题描述
targetSdk > 30时且使用后台更新模式,显示apk下载完成通知时会抛出异常,异常信息如下:
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
原因是Android12的新特性,要求应用创建的每个PendingIntent对象都要指定可变性, 使用flag只能为PendingIntent.FLAG_MUTABLE 或PendingIntent.FLAG_IMMUTABLE,而在
com.xuexiang.xupdate.service.DownloadService#showDownloadCompleteNotification()
在创建PendingIntent时指定的flag是PendingIntent.FLAG_UPDATE_CURRENT。使用的XUpdate版本(必填)
2.4.1
如何重现(必填)
1.项目的targetSdk > 30(31及以上)
2.设置supportBackgroundUpdate(true)
3.点击后台更新
期望的效果
建议创建PendingIntent时判断当前系统版本,根据不同系统版本创建带有不同flag的PendingIntent,如下:
截图
![异常信息](https://private-user-images.githubusercontent.com/23159320/273790017-68eb68ea-4cdb-4169-8775-cd0419ec473c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY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zUFFLNFpBJTJGMjAyNDA4MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI2VDIzNDYzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAwNTM2MWVjZjIxMTIyODYxMjdlZWFhNTFjYTEwMzc1OTM1MmMwNDZhYjA5ZGRlZmM0MTkwYWU5NjNlNDE4YTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lt6X8WfaytCpxuMu3GQTt5Ai7gj8tOZbJqYdyX6oEds)
设备信息
The text was updated successfully, but these errors were encountered: