'App is freezing in Samsung models after fixing for S+ Targeting S+ (version 31 and above)

I have an app, it makes crashes after updating to the sdk 31, I have fixed with adding the FLAG_IMMUTABLEs. But now the app not crashing. It shows the app freezing in widgets. Any thoughts on this.

Unable to start receiver .widget.WidgetProvider: java.lang.IllegalArgumentException: : 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.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source