Question

Would someone explain me the role of flags in functions like setFlags? What exactly does this word mean in that situation...?

My example is

protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(new RenderView(this));
}

I'd like to know what is setFlags used for?

I've read the API documentation, but I haven't understood that.

Était-ce utile?

La solution

Simply think of flags as features that you're applying to the object (in this case to the object Window), and they are represented as integers. You can apply the flags using the final variables in Window and WindowManager.LayoutParams.

setFlags replaces current flags. addFlags appends more flags and does not replace the current ones.

Autres conseils

Basically setFlag() is used for as per our application requirement there are lots of flag available for that like

Window flag, Intent flag etc..

this flags is used some situation where we want to achieve some functionality at programitically for example

for Intent Flag

mintent.setFlag(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

which means all other activity will be clear which before you open at application execution.

As per your code Window flag

It will set your application screen full screen by programatically

Applications screens say activity has some view associated with it. There are different ways to present your content, ie title bar, without title bar, full screen, auto screen lock, without auto screen lock... etc, to set this properties to your activity you tell the screen via setting this window flags, now there are some flags which need to be set before calling setContentView, so in your code you are trying to make your window full screen and to make flags effective you call setContentView explicitly. To know more what you can do with your window to display content is different cases refer this : http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top