teprinciple / UpdateAppUtils

一行代码快速实现app版本更新
1.09k stars 223 forks source link

android 12 适配 #103

Open jinlongwu opened 1 year ago

jinlongwu commented 1 year ago

PACKAGE_NAME: Targeting S+ (version 10000 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.

jinlongwu commented 1 year ago
 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
            //android 12 必须使用 PendingIntent.FLAG_MUTABLE 模式
            val pendingIntent = PendingIntent.getActivity(
                context, REQUEST_CODE, intent, PendingIntent.FLAG_MUTABLE
            )
            builder.setContentIntent(pendingIntent)

        } else {
            val pendingIntent = PendingIntent.getActivity(
                context,
                REQUEST_CODE, intent,
                PendingIntent.FLAG_ONE_SHOT
            );
            builder.setContentIntent(pendingIntent)
        }