Activity stack ordering problem when launching application from Android app installer and from Home screen

Added the answer that antonyt provided: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { // Activity was brought to front and not created, // Thus finishing this will get us to the last viewed activity finish(); return; } // Regular activity creation code… }

Storing EnumSet in a database?

Storing the ordinal as a representation of the EnumSet is not a good idea. The ordinal numbers depend on the order of the definition in the Enum class (a related discussion is here). Your database may be easily broken by a refactoring that changes the order of Enum values or introduces new ones in the … Read more

overridePendingTransition does not work when FLAG_ACTIVITY_REORDER_TO_FRONT is used

Actually the right solution when using REORDER_TO_FRONT is to call overridePendingTransition in the method onNewIntent() of the activity you are going to open. @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } replace with your transitions. If you need to selectively replace the transition you can add an extra in your intent and check … Read more

PHP function flags, how?

Flags must be powers of 2 in order to bitwise-or together properly. define(“FLAG_A”, 0x1); define(“FLAG_B”, 0x2); define(“FLAG_C”, 0x4); function test_flags($flags) { if ($flags & FLAG_A) echo “A”; if ($flags & FLAG_B) echo “B”; if ($flags & FLAG_C) echo “C”; } test_flags(FLAG_B | FLAG_C); # Now the output will be BC Using hexadecimal notation for the … Read more

Checking flag bits java

To check to see if a bit value is set: int value = VALUE_TO_CHECK | OTHER_VALUE_TO_CHECK; if ((value & VALUE_TO_CHECK) == VALUE_TO_CHECK) { // do something–it was set } if ((value & OTHER_VALUE_TO_CHECK) == OTHER_VALUE_TO_CHECK) { // also set (if it gets in here, then it was defined in // value, but it does not … Read more