0

I am new to android and this might be a silly question but i really do not understand the meaning of flags . I tried searching for it but did'nt get much .

Did not understand what is in this link even - The meaning of FLAG_ACTIVITY_SINGLE_TOP in Android

can anyone explain in simple terms .

Community
  • 1
  • 1
Abhimanyu
  • 29
  • 4

1 Answers1

0

The term "flag", used in the computer industry, is a generic term for a switch or indicator that requests a particular option. In a command-line interface (CLI), command flags choose various options for the command. In an API, method flags set a particular option for an object or action. In most programming languages, the field set by a flag is an integer, and the flag itself is an integer constant. The Java standard is to name flag constants in uppercase, and define their values as integer powers of 2. As a result, if you want to set more than one flag for the same field, you can logical OR the flags. Flag semantics depend on the object. For an Intent, some flags control how the system handles an Activity when you try to start it. The OP's link talks about FLAG_ACTIVITY_SINGLE_TOP. To understand that flag, you have to understand how tasks work in Android. The simple (and somewhat naive) explanation is that the flag ensures that a user that's already in an Activity instance goes back to that instance after going away from it. You would mostly use it if you have an Activity that sends an Intent to start another Activity to accomplish an operation.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18