2010-05-12 10 views

Respuesta

30
/** 
    * Display a dialog that user has no internet connection 
    * @param ctx1 
    * 
    * Code from: http://osdir.com/ml/Android-Developers/2009-11/msg05044.html 
    */ 
    public static void showNoConnectionDialog(Context ctx1) { 
     final Context ctx = ctx1; 
     AlertDialog.Builder builder = new AlertDialog.Builder(ctx); 
     builder.setCancelable(true); 
     builder.setMessage(R.string.no_connection); 
     builder.setTitle(R.string.no_connection_title); 
     builder.setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int which) { 
       ctx.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); 
      } 
     }); 
     builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int which) { 
       return; 
      } 
     }); 
     builder.setOnCancelListener(new DialogInterface.OnCancelListener() { 
      public void onCancel(DialogInterface dialog) { 
       return; 
      } 
     }); 

     builder.show(); 
    } 
+1

esto es realmente muy útil, yo también había implementado el mismo que el tuyo. Pero aún así puedes ayudarme a resolverlo: http://stackoverflow.com/questions/3889241/wireless-settings-dialog –

Cuestiones relacionadas