@@ -39,7 +39,8 @@ public void onReceive(Context context, Intent intent) {
39
39
ft .replace (R .id .main_fragment_status , fragmentList );
40
40
ft .setTransition (FragmentTransaction .TRANSIT_FRAGMENT_FADE );
41
41
ft .commit ();
42
- } else if (IodineVpnService .ACTION_STATUS_CONNECT .equals (intent .getAction ())) {
42
+ } else if (IodineVpnService .ACTION_STATUS_CONNECT .equals (intent .getAction ())
43
+ || IodineVpnService .ACTION_STATUS_CONNECTED .equals (intent .getAction ())) {
43
44
// Switch to Status Fragment
44
45
FragmentTransaction ft = getFragmentManager ().beginTransaction ();
45
46
ft .replace (R .id .main_fragment_status , fragmentStatus );
@@ -57,12 +58,6 @@ protected void onCreate(Bundle savedInstanceState) {
57
58
58
59
mConfigDatabase = new ConfigDatabase (this );
59
60
60
- IntentFilter intentFilterStatusUpdates = new IntentFilter ();
61
- intentFilterStatusUpdates .addAction (IodineVpnService .ACTION_STATUS_CONNECT );
62
- intentFilterStatusUpdates .addAction (IodineVpnService .ACTION_STATUS_ERROR );
63
- intentFilterStatusUpdates .addAction (IodineVpnService .ACTION_STATUS_IDLE );
64
- registerReceiver (broadcastReceiverStatusUpdates , intentFilterStatusUpdates );
65
-
66
61
startService (new Intent (this , IodineVpnService .class ));
67
62
}
68
63
@@ -73,8 +68,27 @@ public boolean onCreateOptionsMenu(Menu menu) {
73
68
}
74
69
75
70
@ Override
76
- protected void onDestroy () {
71
+ protected void onResume () {
72
+ super .onResume ();
73
+ IntentFilter intentFilterStatusUpdates = new IntentFilter ();
74
+ intentFilterStatusUpdates .addAction (IodineVpnService .ACTION_STATUS_CONNECT );
75
+ intentFilterStatusUpdates .addAction (IodineVpnService .ACTION_STATUS_CONNECTED );
76
+ intentFilterStatusUpdates .addAction (IodineVpnService .ACTION_STATUS_ERROR );
77
+ intentFilterStatusUpdates .addAction (IodineVpnService .ACTION_STATUS_IDLE );
78
+ registerReceiver (broadcastReceiverStatusUpdates , intentFilterStatusUpdates );
79
+
80
+ Log .d (TAG , "Request CONTROL_UPDATE" );
81
+ sendBroadcast (new Intent (IodineVpnService .ACTION_CONTROL_UPDATE ));
82
+ }
83
+
84
+ @ Override
85
+ protected void onPause () {
77
86
unregisterReceiver (broadcastReceiverStatusUpdates );
87
+ super .onPause ();
88
+ }
89
+
90
+ @ Override
91
+ protected void onDestroy () {
78
92
mConfigDatabase .close ();
79
93
super .onDestroy ();
80
94
}
@@ -89,14 +103,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
89
103
.setCancelable (true )//
90
104
.create () //
91
105
.show ();
106
+ scanner .close ();
92
107
} else if (item .getItemId () == R .id .menu_main_add ) {
93
108
startActivity (new Intent (this , IodinePref .class ));
94
109
}
95
110
return super .onOptionsItemSelected (item );
96
111
}
97
-
98
-
99
- private void vpnServiceDisconnect () {
100
- sendBroadcast (new Intent (IodineVpnService .ACTION_CONTROL_DISCONNECT ));
101
- }
102
112
}
0 commit comments