Private Boolean networkstatus (){
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); // if you need to perform the operation again after the setting is complete, you can rewrite the operation code.
}
}). Setneutralbutton ("no", new dialoginterface. onclicklistener (){
Public void onclick (dialoginterface dialog, int whichbutton ){
Dialog. Cancel ();
}
}). Show ();
}
Return netsataus;
}