Skip to content

Instantly share code, notes, and snippets.

@joecks
Created January 17, 2013 20:16
Show Gist options
  • Save joecks/4559331 to your computer and use it in GitHub Desktop.
Save joecks/4559331 to your computer and use it in GitHub Desktop.
Prints all flags of an Android Intent, which is very useful for debugging Intents!
Field[] declaredFields = Intent.class.getDeclaredFields();
for (Field field : declaredFields) {
if (field.getName().startsWith("FLAG_")) {
try {
int flag = field.getInt(null);
if ((intent.getFlags() & flag) != 0) {
log.d(field.getName());
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
@embray
Copy link

embray commented Aug 22, 2023

Nice one, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment