ava.lang.IllegalArgumentException: com.example.myapplication: 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.
说白了安卓12以后要求使用固定模式:
PendingIntent pendingIntent = PendingIntent.getActivity
(this, 0, intent, PendingIntent.FLAG_IMMUTABLE);
过去习惯的都是
PendingIntent pendingIntent=PendingIntent.getActivity
(this,0,intent,PedingIntent.FLAG_UPDATGE_CURRENT);
改了之后便正常了。
劝各位别随便用最新的sdk。