Question

I can run this code in my computer:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);  

inside onResume(). I sent the code to someone else for testing. But they tell me that that this line shows an error in their SDK, and replacing it with

getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);  

works, while in my case, both the codes work. Why is this happening?

PS: My SDK version is the one with the zip file name adt-bundle-windows-x86-20130522. I am not sure the exact version they are using, but it is newer than mine.

Was it helpful?

Solution

WindowManager is a class in the Android SDK. Its fully qualified name is android.view.WindowManager. The WindowManager.LayoutParams is a nested class of WindowsManager and its fully qualified name is android.view.WindowManager.LayoutParams

You can either specify the fully qualified name when you want to use it.

getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);  

or you can import its outer class

import android.view.WindowManager;

and use it directly

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top