瀏覽代碼

unregister broadcast in onDestroy

Julien Clauter 9 年之前
父節點
當前提交
02c65a9577

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/sync/wifi_direct/WiFiP2pEventHandler.java

@@ -51,7 +51,7 @@ public class WiFiP2pEventHandler implements WifiP2pManager.ChannelListener {
     }
 
     public void onPause() {
-        if (receiver == null) {
+        if (receiver != null) {
             activity.unregisterReceiver(receiver);
             receiver = null;
         }

+ 6 - 0
src/de/tudarmstadt/informatik/hostage/sync/wifi_direct/ui/WiFiP2pSyncActivity.java

@@ -108,6 +108,12 @@ public class WiFiP2pSyncActivity extends Activity implements AdapterView.OnItemC
         super.onStop();
     }
 
+    @Override
+    protected void onDestroy(){
+        this.wifiEventHandler().onPause();
+        super.onDestroy();
+    }
+
     private WiFiP2pEventHandler.WiFiP2pEventListener eventListener(){
         if (_p2pEventListener == null){
             _p2pEventListener = new WiFiP2pEventHandler.WiFiP2pEventListener() {