简体   繁体   中英

What is the difference between specifying a class in these two ways?

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.

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);  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM