Contiuned from : This is my question
So now i can use this code :
Window a = getWindow();
a.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Instead of this code :
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
And some of my Senior’s said that because of getWindow(); method is returning a Window Object we can use both of the code above.
My question is : why we need to get a returned Window object from this code : Window a = getWindow();
I think when i do this i already have a Window Object
Window a;
But why is it not working?
And my 2nd question is why can’t i do like this :
Window a = new Window();
I think it’s create a Window object too.
Why must I use the getWindow(); method?
Thanks all
PS: English is not my native language, so sorry if I made some mistakes
I’m assuming java here:
does not create a new
Windowobject, it only creates a variable, which can hold an object of typeWindow. To create the object itself – you need to invoke its constructor, in your case – I assume that whatgetWindow()does.Also,
new Windowis a syntax error – constructors in java are invoked similar to methods [with()and relevant arguments, if there are any].