Here is the way to check your Android Wifi and 3G connectivity network status which is connected to your Phone by using a code to check the current status of your Android network status and using the permission:
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.widget.Toast;
public class pingtest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
chkStatus();
}
void chkStatus()
{
final ConnectivityManager connMgr = (ConnectivityManager)
this.getSystemService(Context.CONNECTIVITY_SERVICE);
final android.net.NetworkInfo wifi =
connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
final android.net.NetworkInfo mobile =
connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
Hello, thank you for this code. I'm not a experienced android programmer, I'm doing a not big project for android and im using this code, but when I put in on Eclipse, on the 2.2 android SDK, it shows me an error on the permissions. It says: "Syntax error on tokens". what could it be?
2 comments:
Hello, thank you for this code. I'm not a experienced android programmer, I'm doing a not big project for android and im using this code, but when I put in on Eclipse, on the 2.2 android SDK, it shows me an error on the permissions. It says: "Syntax error on tokens". what could it be?
Tks dude
Post a Comment