Please see the code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
receiverWifi = new WifiReceiver();
mIntentFilter = new IntentFilter();
final IntentFilter mIFNetwork = new IntentFilter();
mIFNetwork.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION); //"android.net.conn.CONNECTIVITY_CHANGE"
registerReceiver(receiverWifi, mIFNetwork);
// mainWifi.startScan();
haveNetworkConnection() ;
}// end of the function
and
class WifiReceiver extends BroadcastReceiver {
public void onReceive(Context c, Intent intent) {
// Toast.makeText(SecondActivity.this, "Message is show", Toast.LENGTH_LONG).show();
// haveNetworkConnection() ;
boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
if (noConnectivity) {
ImageButton b=(ImageButton)findViewById(R.id.button4);
b.setBackgroundResource(R.drawable.lightedbutton_off);
} else {
ImageButton b=(ImageButton)findViewById(R.id.button4);
b.setBackgroundResource(R.drawable.lightedbutton_on);
}
}//
}
i want to on the button when only device is connected with wifi , but using above code condition becomes true if device is also connected with edge/gprs Please how can I do this