How can I check if my device already connected or not?
Here is code I used on my Main Menu:
ConnectivityManager connManager = (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo m3g = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (mWifi.isConnected() || m3g.isConnected()) {
try {
db.Connect();
Intent intent = new Intent(this, LoginActivity.class);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
} else if (mWifi.isConnected() == false & m3g.isConnected() == false) {
//alert
}
It work perfectly but when you quit app and didn't logout, the next time you open application it will open the activity you leave last time not the Main Menu so i can't check connection
So I want to know is there anyway I can alway check device connection ?
Sorry for my English