79293866

Date: 2024-12-19 10:17:35
Score: 4
Natty:
Report link

I looked into source code of unit tests for that rule in AGP linter. They are testing it in various ways but they do not test it with code like mine. So based on Android Code Search I was able to fix my problem with code like:

PendingIntent pendingIntent = null;
int pendingIntentFlags;
if(Build.VERSION.SDK_INT >= VERSION_CODES.M){
    pendingIntentFlags = PendingIntent.FLAG_IMMUTABLE;
} else {
    pendingIntentFlags = 0;
}
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, pendingIntentFlags);

Now linter has no problems with that code.

I still do not know why my previous code was failing on linter, so if anyone have any idea, please share your thoughts in comments because I would like to know.

Reasons:
  • Blacklisted phrase (1.5): I would like to know
  • RegEx Blacklisted phrase (2.5): please share your
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: aFku