Android determines the network status
Android: name = "android. permission. ACCESS_NETWORK_STATE"/>
Private boolean getNetWorkStatus (){
Boolean netSataus = false;
ConnectivityManager cwjManager = (ConnectivityManager) getSystemService (Context. CONNECTIVITY_SERVICE );
CwjManager. getActiveNetworkInfo ();
If (cwjManager. getActiveNetworkInfo ()! = Null ){
NetSataus = cwjManager. getActiveNetworkInfo (). isAvailable ();
}
If (! NetSataus ){
Builder B = new AlertDialog. Builder (this). setTitle ("no available network ")
. SetMessage ("do you want to set the network? ");
B. setPositiveButton ("yes", new DialogInterface. OnClickListener (){
Public void onClick (DialogInterface dialog, int whichButton ){
Intent mIntent = new Intent ("/");
ComponentName comp = new ComponentName (
"Com. android. settings ",
"Com. android. settings. WirelessSettings ");
MIntent. setComponent (comp );
MIntent. setAction ("android. intent. action. VIEW ");
StartActivityForResult (mIntent, 0 );
}
}). SetNeutralButton ("no", new DialogInterface. OnClickListener (){
Public void onClick (DialogInterface dialog, int whichButton ){
Dialog. cancel ();
}
}). Show ();
}
Return netSataus;
}