简体   繁体   中英

Android - activity state when top sliding menu is dragged down?

I have a simple app which displays if the phone is connected to Wifi, 3G or has GPS enabled. Now, I want to update my app when the user goes to the top sliding menu and enables/disables any of those three. Currently, everything is done on onCreate() and it works well, but I have to restart the app to see the changes. Which method should I call (Override) in order to get the app show the updated data ie I have no idea what state the app is in when the sliding menu is dragged on top of it. Thanks

Take a look at this article to setup listeners so that you can monitor the wifi/3g and gps: http://www.grokkingandroid.com/android-getting-notified-of-connectivity-changes/

The idea is that you will want to register a receiver to monitor the wifi connection state intent. Every time the state changes, Android will notify all listeners (you being one of them now) and you can perform the code you require to update your UI. This also applies to 3G and GPS but by using different intents.

In addition to Sams answer and your question most probable method you are looking for is the onResume() method.

@Override
public void onResume(){

}

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