新版本android sdk开发pendingintentbug

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。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容