Fixed: pause -> onPause, resume -> onResume

Make sure the ssid we are connected to is not null.  This happens when
a network has been updated/removed while we are still connected to it.

Make errorCount an instance variable.




git-svn-id: https://zxing.googlecode.com/svn/trunk@1474 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
vikrama 2010-07-09 17:14:04 +00:00
parent ecbf50da87
commit b5619824c8
2 changed files with 9 additions and 8 deletions

View file

@ -44,13 +44,9 @@ public class WifiActivity extends Activity {
private WifiReceiver wifiReceiver;
private boolean receiverRegistered;
private int networkId;
private static int errorCount;
private int errorCount;
private IntentFilter mWifiStateFilter;
static {
errorCount = 0;
}
public void gotError(){
final int maxErrorCount = 3;
errorCount++;
@ -243,14 +239,18 @@ public class WifiActivity extends Activity {
changeNetwork(setting);
}
public void pause() {
@Override
public void onPause() {
super.onPause();
if (receiverRegistered) {
unregisterReceiver(wifiReceiver);
receiverRegistered = false;
}
}
public void resume() {
@Override
public void onResume() {
super.onResume();
if (wifiReceiver != null && mWifiStateFilter != null && !receiverRegistered) {
registerReceiver(wifiReceiver, mWifiStateFilter);
receiverRegistered = true;
@ -259,6 +259,7 @@ public class WifiActivity extends Activity {
@Override
protected void onDestroy() {
super.onDestroy();
if (wifiReceiver != null) {
if (receiverRegistered) {
unregisterReceiver(wifiReceiver);

View file

@ -60,7 +60,7 @@ final class WifiReceiver extends BroadcastReceiver {
final NetworkInfo.State state = i.getState();
final String ssid = mWifiManager.getConnectionInfo().getSSID();
if (state == NetworkInfo.State.CONNECTED){
if (state == NetworkInfo.State.CONNECTED && ssid != null){
mWifiManager.saveConfiguration();
final String label = parent.getString(R.string.wifi_connected);
statusView.setText(label + "\n" + ssid);