Public void onwindowfocuschanged (Boolean hasfocus) {// todo auto-generated method stubsystem. out. println ("hasfocus --- >>>" + hasfocus); super. onwindowfocuschanged (hasfocus); try {object service = getsystemservice ("statusbar"); Class <?> Statusbarmanager = Class. forname ("android. app. statusbarmanager "); method test = statusbarmanager. getmethod ("collapse"); test. invoke (service);} catch (exception ex) {ex. printstacktrace ();}}
Onwindowfocuschanged is the method in the activity. When this statement is executed, it indicates that the activity has been loaded.
Remember to add permissions:
<Uses-Permission Android: Name = "android. Permission. expand_status_bar"/> <! -- <Uses-Permission Android: Name = "android. Permission. status_bar"/> -->
4.1 simulator test is useful, Huawei c8812 test is useful, but the bug exists .........