1
我有一個activity1檢查互聯網連接,如果用戶沒有互聯網連接,應用程序將他發送到無線設置。期待更改互聯網連接
我想知道如何檢查用戶是否激活了互聯網數據,當他回到活動1稱爲無線設置。
我希望你的幫助。 謝謝。
public void myThread(){
Thread th=new Thread(){
@Override
public void run(){
splash_screen.this.runOnUiThread(new Runnable() {
public void run() {
dialog.conectarRed().show();
}
});
}
};
th.start();
}
}
public Dialog conectarRed() {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
return builder
.setTitle("No hay Conexi�n a Internet")
.setMessage("� Desea activar la Conexi�n de Datos ?")
.setCancelable(false)
.setPositiveButton("Aceptar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent i = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
((Activity) context).startActivity(i);
dialog.cancel();
}
})
.setNegativeButton("Cancelar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
((Activity) context).finish();
dialog.cancel();
}
}).create();
}