public void Activar(View view) {
    String codigo = editCodigoActivacion.getText().toString();

    if (codigo.equalsIgnoreCase(Codigo.codigo)) {
      SharedPreferences.Editor editor = Codigo.prefs.edit();
      editor.putString("Activacion", "Activado");
      editor.commit();

      AlertDialog.Builder alerta = new AlertDialog.Builder(CodigoActivacion.this);
      alerta.setTitle("Activado");
      alerta.setMessage("El producto se ha activado satisfactoriamente");
      alerta.setPositiveButton(
          "Aceptar",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
              Intent intent = new Intent(CodigoActivacion.this, MenuPrincipal.class);
              startActivity(intent);
              finish();
            }
          });
      alerta.setCancelable(false);
      alerta.show();

    } else {
      AlertDialog.Builder alerta = new AlertDialog.Builder(CodigoActivacion.this);
      alerta.setTitle("Código");
      alerta.setMessage("El código ingresado no es correcto, debe ingresar un código valido");
      alerta.setPositiveButton("Aceptar", null);
      alerta.setCancelable(false);
      alerta.show();
    }
  }
Esempio n. 2
0
 @Override
 protected Dialog onCreateDialog(int id) {
   Dialog dialog = null;
   AlertDialog.Builder builder = null;
   if (id == DIALOG_USB_WARNING) {
     builder = new AlertDialog.Builder(this);
     builder.setTitle(R.string.uart_usb_switch_dialog_title);
     builder.setCancelable(false);
     builder.setMessage(getString(R.string.uart_usb_switch_warning));
     builder.setPositiveButton(R.string.ok, null);
     dialog = builder.create();
   } else if (id == DIALOG_USB_CONNECT_WARNING) {
     builder = new AlertDialog.Builder(this);
     builder.setTitle(R.string.uart_usb_switch_dialog_title_error);
     builder.setCancelable(false);
     builder.setMessage(getString(R.string.uart_usb_switch_dialog_usb_error));
     builder.setPositiveButton(
         R.string.ok,
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
             finish();
           }
         });
     dialog = builder.create();
   }
   return dialog;
 }
Esempio n. 3
0
    protected void onPostExecute(Void paramVoid) {

      Log.i("staut===", "====" + statut);
      if (this.statut.equalsIgnoreCase("1")) {
        Paiment.this.ad.dismiss();
        run_statut = true;

        try {
          AlertDialog.Builder localBuilder = new AlertDialog.Builder(Paiment.this);
          localBuilder.setTitle("Your taxi is ordered, follow him on your phone.");
          localBuilder
              .setCancelable(false)
              .setPositiveButton(
                  "Ok",
                  new DialogInterface.OnClickListener() {
                    public void onClick(
                        DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
                      Paiment.this.finish();
                      Intent localIntent = new Intent(Paiment.this, Sui_taxi.class);
                      mp.stop();
                      startActivity(localIntent);
                      paramAnonymousDialogInterface.cancel();
                    }
                  });
          localBuilder.create().show();
          mp.start();
          return;
        } catch (Exception ae) {

        }
      } else if (this.statut.equalsIgnoreCase("-1")) {
        Paiment.this.ad.dismiss();
        try {
          AlertDialog.Builder localBuilder = new AlertDialog.Builder(Paiment.this);
          localBuilder.setTitle("Your request is declined.Please try for another taxi.");
          localBuilder
              .setCancelable(false)
              .setPositiveButton(
                  "Ok",
                  new DialogInterface.OnClickListener() {
                    public void onClick(
                        DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
                      Paiment.this.finish();
                      Intent localIntent = new Intent(Paiment.this, Taxi_map.class);
                      startActivity(localIntent);
                      paramAnonymousDialogInterface.cancel();
                    }
                  });
          localBuilder.create().show();
          return;
        } catch (Exception ae) {

        }
      }
      this.statut.equalsIgnoreCase("fail_connection");
    }
 /**
  * Tests if the game has ended. It tests if you have lost or you won and you can continue to the
  * next word. It gives the message to the user with a dialog.
  */
 public void gameEnd() {
   // the player has no guesses left and lost
   if (game.leftGuesses == 0) {
     AlertDialog.Builder end = new AlertDialog.Builder(GameActivity.this);
     end.setTitle(R.string.gameover);
     end.setMessage(getResources().getString(R.string.end) + game.word);
     end.setPositiveButton(
         R.string.end_button,
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             Intent intent = new Intent(GameActivity.this, HighscoreActivity.class);
             intent.putExtra("gamescore", game.score);
             intent.putExtra("wordlength", game.setLength);
             if (evilType) {
               intent.putExtra("gametype", "evil");
             } else {
               intent.putExtra("gametype", "good");
             }
             startActivity(intent);
             finish();
           }
         });
     // he must go to the highscorescreen
     end.setCancelable(false);
     end.create();
     end.show();
     // All the letters of the word have been guessed
   } else if (game.wordString().indexOf("-") < 0) {
     // The player gets a point
     game.addScore(1);
     AlertDialog.Builder end = new AlertDialog.Builder(GameActivity.this);
     end.setTitle(R.string.guessed);
     end.setMessage(getResources().getString(R.string.guess_end) + game.word);
     end.setPositiveButton(
         R.string.next_word,
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             nextWord();
           }
         });
     // The player must go to the next word
     end.setCancelable(false);
     end.create();
     end.show();
   }
 }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      AlertDialog.Builder adb = new AlertDialog.Builder(this);
      adb.setCancelable(true);

      adb.setNeutralButton(
          "Yes",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
              // TODO Auto-generated method stub
              // CODE TO EXTEND RESERVATION
              finish();
            }
          });

      adb.setMessage("Do you Want to Exit");
      adb.show();

      adb.setNegativeButton(
          "No",
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface arg0, int arg1) {
              // TODO Auto-generated method stub

            }
          });
      return true;
    }
    return super.onKeyDown(keyCode, event);
  }
  public static void showOKDialog(Context context, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("Safar");
    builder.setMessage(message);
    builder.setCancelable(true);
    builder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {

            dialog.cancel();
          }
        });
    //        builder1.setNegativeButton("No",
    //                new DialogInterface.OnClickListener() {
    //                    public void onClick(DialogInterface dialog, int id) {
    //                        dialog.cancel();
    //                    }
    //                });
    //        builder.setNeutralButton("Close", new DialogInterface.OnClickListener() {
    //
    //            @Override
    //            public void onClick(DialogInterface arg0, int arg1) {
    //                // TODO Auto-generated method stub
    //                Toast.makeText(getApplicationContext(), "Close is clicked",
    // Toast.LENGTH_LONG).show();
    //
    //            }
    //        });
    //        dialog.setCancelable(true);
    //        dialog.setCanceledOnTouchOutside(false);
    AlertDialog alert = builder.create();
    alert.show();
  }
  private void showAlert() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder
        .setCancelable(true)
        .setTitle("Really delete???")
        .setInverseBackgroundForced(true)
        .setPositiveButton(
            "Yes",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                if (selectedChildRowId.equals("-1"))
                  foodsWeightDBAdapter.deleteParentRowById(selectedParentRowId);
                else foodsWeightDBAdapter.deleteChildRowById(selectedChildRowId);
                displayListView();
                dialog.dismiss();
              }
            })
        .setNegativeButton(
            "No",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
              }
            });
    AlertDialog alert = builder.create();
    alert.show();
  }
Esempio n. 8
0
  @Override
  protected Dialog onCreateDialog(int id, Bundle args) {

    // final String [] didYouKnow = getResources().getStringArray(R.array.did_you_know);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    switch (RunProcessor.Mode.values()[id]) {
      case LOAD:
        builder.setTitle("Loading Image");
        break;
      case LOAD_ALIGN:
        builder.setTitle(getResources().getString(R.string.aligning_form));
        break;
      case PROCESS:
        builder.setTitle(getResources().getString(R.string.processing_form));
        builder.setMessage(
            "The first time you use a template this will be slow because the classifier is being trained.");
        break;
      default:
        return null;
    }
    builder.setCancelable(false);
    //		.setMessage("Did you know... \n " + didYouKnow[(new Random()).nextInt(didYouKnow.length)]);

    return builder.create();
  }
 @Override
 public void onBackPressed() {
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setCancelable(false);
   builder.setMessage("Do you want back to menu?");
   builder.setPositiveButton(
       "Yes",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           // if user pressed "yes", then he is allowed to exit from application
           mediaPlayer.pause();
           finish();
         }
       });
   builder.setNegativeButton(
       "No",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           // if user select "No", just cancel this dialog and continue with app
           dialog.cancel();
         }
       });
   AlertDialog alert = builder.create();
   alert.show();
 }
Esempio n. 10
0
  private void promptScoutName() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Enter your name");
    builder.setCancelable(false);

    // Set up the input
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);

    // Affirmative response
    builder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            scout = input.getText().toString().toUpperCase();
            if (scout.equals("")) promptScoutName();
            else {
              getPreferences(MODE_PRIVATE)
                  .edit()
                  .putString(getString(R.string.preference_scout), scout)
                  .apply();
              updateNameField();
            }
          }
        });
    builder.show();
  }
  /** 显示帐号在别处登录dialog */
  private void showConflictDialog() {
    isConflictDialogShow = true;
    DemoHXSDKHelper.getInstance().logout(false, null);
    String st = getResources().getString(R.string.Logoff_notification);
    if (mycontext.isFinishing()) {
      // clear up global variables
      try {
        if (conflictBuilder == null)
          conflictBuilder = new android.app.AlertDialog.Builder(mycontext);
        conflictBuilder.setTitle(st);
        conflictBuilder.setMessage(R.string.connect_conflict);
        conflictBuilder.setPositiveButton(
            R.string.ok,
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                conflictBuilder = null;
                finish();
                startActivity(new Intent(mycontext, LoginContainerActivity.class));
              }
            });
        conflictBuilder.setCancelable(false);
        conflictBuilder.create().show();
        isConflict = true;
      } catch (Exception e) {
        EMLog.e(TAG, "---------color conflictBuilder error" + e.getMessage());
      }
    }
  }
Esempio n. 12
0
  private void internetAvailabilityAlert(final Context context, String message) {
    AlertDialog.Builder bld = new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_LIGHT);
    bld.setTitle("zenApp");
    bld.setMessage(message);
    bld.setCancelable(false);
    bld.setPositiveButton(
        "Ok",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        });
    bld.setNegativeButton(
        "Retry",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            tryToLoadUrl(context);
          }
        });

    bld.create().show();
  }
Esempio n. 13
0
  /** Show a dialog asking if unsaved edits should be ignored. Finish if so. */
  public static void showConfirmUnsavedEditsDialog(final Activity a) {
    AlertDialog.Builder dialog = new Builder(a);

    dialog.setTitle(R.string.confirm_exit);
    dialog.setMessage(R.string.you_may_have_unsaved_changes);

    dialog.setPositiveButton(
        R.string.ok,
        new AlertDialog.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            a.finish();
          }
        });

    dialog.setNegativeButton(
        R.string.cancel,
        new AlertDialog.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        });
    dialog.setCancelable(false);
    dialog.create().show();
  }
Esempio n. 14
0
    @Override
    protected void onPostExecute(String result) {
      if (result == "0") {
        Toast.makeText(context, "无法连接到网络,请检查网络配置", Toast.LENGTH_LONG).show();
      }
      try {

        JSONObject jObject = new JSONObject(result);
        isExit = jObject.getBoolean("is_Exit");
        if (isExit) {
          return;
        } else {
          AlertDialog.Builder builder = new AlertDialog.Builder(context);
          builder.setTitle("同校网");
          builder.setMessage("账号或者密码错误");
          builder.setCancelable(false);
          builder.setPositiveButton(
              "确定",
              new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = new Intent(DreamActivity.this, loginActivity.class);
                  startActivity(intent);
                  DreamActivity.this.finish();
                }
              });
          builder.show();
        }

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  public void makeUseLocation(Location location) {
    if (location != null) {
      this.atual = new Coordenada(location.getLatitude(), location.getLongitude());
      for (LocationObserver observer : observers) {
        observer.mudouLocalizacaoPara(atual);
      }
    } else {
      AlertDialog.Builder dialog = new AlertDialog.Builder(context);
      dialog.setTitle("Ocorreu um erro :(");
      dialog.setMessage("Infelizmente não foi possível obter sua localização.");
      dialog.setCancelable(true);
      dialog.setPositiveButton(
          "Quero habilitar o GPS",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              Intent gpsIntent =
                  new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
              context.startActivity(gpsIntent);
            }
          });
      dialog.setNegativeButton(
          "Agora não",
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              // TODO ?
            }
          });
      dialog.show();
    }
  }
Esempio n. 16
0
  public Dialog showCustomAlert(
      Activity activity,
      String title,
      String message,
      boolean cancelable,
      String positiveButton,
      String negativeButton) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    if (title != null) {
      builder = builder.setTitle(title);
    }
    if (message != null) {
      builder = builder.setMessage(message);
    }
    builder = builder.setCancelable(cancelable);

    if (positiveButton != null) {
      builder = builder.setPositiveButton(positiveButton, dialogClickListener);
    }
    if (negativeButton != null) {
      builder = builder.setNegativeButton(negativeButton, dialogClickListener);
    }

    Dialog d = builder.create();
    dialogs.add(d);
    d.show();

    return d;
  }
Esempio n. 17
0
 public void showMessage1(String title, String Message) {
   AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
   builder.setCancelable(true);
   builder.setTitle(title);
   builder.setMessage(Message);
   builder.show();
 }
  /*
   *  Method: startGame
   *  Purpose: finishes the current activity and switches to the game
   */
  public void startGame(View view) {
    int counter = 0;
    for (int i = 0; i < ships.length; i++) {
      if (ships[i].getPlaced()) {
        counter++;
      }
    }
    if (counter == 5) {
      if (p2.setUpAi()) {
        Intent startGame = new Intent(this, MainActivity.class); // needs to be a new AI class
        startGame.putExtra("Player1", p1);
        startGame.putExtra("Player2", p2);
        startGame.putExtra("isAI", true);
        startActivity(startGame);
        finish();
      }
    } else {
      AlertDialog.Builder deletePrompt = new AlertDialog.Builder(this);
      deletePrompt.setMessage("You must place five ships");
      deletePrompt.setCancelable(false);
      deletePrompt.setPositiveButton(
          "Ok",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
            }
          });

      AlertDialog alert = deletePrompt.create();
      alert.show();
    }
  }
Esempio n. 19
0
  /**
   * 指定のIntentがNotActivityFoundExceptionにならずに使えるか調べる<br>
   * 処理できるアプリが存在しない場合指定のアプリをダウンロードさせる
   *
   * @param context
   * @param intent 処理できるか調べたいIntent
   * @param appName 処理できなかったときダウンロードさせるアプリの名前
   * @param packageName 処理できなかったときダウンロードさせるアプリのpackage名
   * @return 処理できるならtrue, 処理できないならfalse
   */
  public static boolean canResolveActivity(
      Context context, Intent intent, String appName, String packageName) {
    sContext = context;

    ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0);

    // 対応できるAppがインストールされていればそのまま処理
    if (resolveInfo != null) {
      return true;
    }

    // なければ、Marketに取得しにいくか聞く。
    sPackageName = packageName;
    AlertDialog.Builder diagBldr = new AlertDialog.Builder(context);
    diagBldr.setTitle(context.getString(R.string.cant_resolve_intent_title, appName));
    diagBldr.setMessage(context.getString(R.string.cant_resolve_intent_message));

    diagBldr.setPositiveButton(context.getString(R.string.go_market), sOnClick);
    diagBldr.setNegativeButton(context.getString(R.string.ignore), sOnClick);

    diagBldr.setCancelable(true);
    diagBldr.create();
    diagBldr.show();

    return false;
  }
  private void confirmDeleteDialog(OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    View contents = View.inflate(this, R.layout.delete_thread_dialog_view, null);
    TextView msg = (TextView) contents.findViewById(R.id.message);
    msg.setText(R.string.confirm_delete_selected_messages);

    final CheckBox checkbox = (CheckBox) contents.findViewById(R.id.delete_locked);

    if (mSelectedLockedUris.size() == 0) {
      checkbox.setVisibility(View.GONE);
    } else {
      checkbox.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              mIsDeleteLockChecked = checkbox.isChecked();
            }
          });
    }
    builder.setTitle(R.string.confirm_dialog_title);
    builder.setIconAttribute(android.R.attr.alertDialogIcon);
    builder.setCancelable(true);
    builder.setPositiveButton(R.string.yes, listener);
    builder.setNegativeButton(R.string.no, null);
    builder.setView(contents);
    builder.show();
  }
 private void onStartSurvey()
 {
   if (this.mSurveyBegun) {
     return;
   }
   if (!MPConfig.getInstance(this).getTestMode()) {
     trackSurveyAttempted();
   }
   AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
   localBuilder.setTitle(R.string.com_mixpanel_android_survey_prompt_dialog_title);
   localBuilder.setMessage(R.string.com_mixpanel_android_survey_prompt_dialog_message);
   localBuilder.setPositiveButton(R.string.com_mixpanel_android_sure, new DialogInterface.OnClickListener()
   {
     public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
     {
       SurveyActivity.this.findViewById(R.id.com_mixpanel_android_activity_survey_id).setVisibility(0);
       SurveyActivity.access$402(SurveyActivity.this, true);
       SurveyActivity.this.showQuestion(SurveyActivity.this.mCurrentQuestion);
     }
   });
   localBuilder.setNegativeButton(R.string.com_mixpanel_android_no_thanks, new DialogInterface.OnClickListener()
   {
     public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
     {
       SurveyActivity.this.finish();
     }
   });
   localBuilder.setCancelable(false);
   this.mDialog = localBuilder.create();
   this.mDialog.show();
 }
  public AlertDialog makeErrorDialog(
      final Activity context, String error, final String[] permissions, final boolean sso) {
    AlertDialog.Builder builder = dialogFactory.getAlertDialogBuilder(context);
    builder.setTitle("Oops!");
    builder.setMessage("Oops!\nSomething went wrong...\n[" + error + "]");
    builder.setCancelable(false);
    builder.setPositiveButton(
        "Try again",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            authenticate(context, permissions, sso);
          }
        });
    builder.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            finish(context);
          }
        });

    AlertDialog dialog = builder.create();

    return dialog;
  }
Esempio n. 23
0
  protected void initializeAlertDialog() {
    alertDialog = new AlertDialog.Builder(act);
    alertDialog.setCancelable(false);
    // Setting Dialog Title
    alertDialog.setTitle(act.getString(R.string.conex));

    // Setting Dialog Message
    alertDialog.setMessage(act.getString(R.string.conex_question));
    // Setting Icon to Dialog
    // alertDialog.setIcon(R.drawable.delete);

    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton(
        act.getString(R.string.yes),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            act.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            dialog.cancel();
          }
        });

    // Setting Negative "NO" Button
    alertDialog.setNegativeButton(
        act.getString(R.string.no),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            act.finish();
          }
        });
  }
  public Dialog createDevicesDialog() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setTitle("Select device");

    // ペアリング済みデバイスをダイアログのリストに設定する。
    Set<BluetoothDevice> pairedDevices = bluetoothClient.getPairedDevices();
    final BluetoothDevice[] devices = pairedDevices.toArray(new BluetoothDevice[0]);
    String[] items = new String[devices.length];
    for (int i = 0; i < devices.length; i++) {
      items[i] = devices[i].getName();
    }

    alertDialogBuilder.setItems(
        items,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            // 選択されたデバイスを通知する。そのまま接続開始。
            bluetoothClient.doConnect(devices[which]);
          }
        });
    alertDialogBuilder.setCancelable(false);
    return alertDialogBuilder.create();
  }
Esempio n. 25
0
    @Override
    protected void onPostExecute(ArrayList<Category> categories) {
      super.onPostExecute(categories);

      if (categories.size() > 0) {
        CategoryAdapter cAdapter = new CategoryAdapter(Categories.this, categories);
        viewCategories = (AbsListView) findViewById(R.id.view_categories);
        viewCategories.setAdapter(cAdapter);
      } else {

        AlertDialog.Builder builder = new AlertDialog.Builder(Categories.this);
        builder
            .setMessage(R.string.no_connection_text)
            .setTitle(R.string.no_connection_title_text)
            .setPositiveButton(
                R.string.ok,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    System.exit(0);
                  }
                });
        builder.setCancelable(false);
        builder.show();
      }
    }
Esempio n. 26
0
  /**
   * Displays the EULA if necessary. This method should be called from the onCreate() method of your
   * main Activity.
   *
   * @param activity The Activity to finish if the user rejects the EULA
   */
  public static void showEula(final Activity activity) {
    if (!new Eula().shouldShowEula(activity)) return;

    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.DLG_eula_title);
    builder.setCancelable(true);
    builder.setPositiveButton(
        R.string.DLG_accept,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            accept(activity);
          }
        });
    builder.setNegativeButton(
        R.string.DLG_decline,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            refuse(activity);
          }
        });
    builder.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface dialog) {
            refuse(activity);
          }
        });
    builder.setMessage(AndroidUtilities.readFile(activity, R.raw.eula));
    builder.show();
  }
Esempio n. 27
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main12);

    ConnectivityManager cManager =
        (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE);
    NetworkInfo ninfo = cManager.getActiveNetworkInfo();
    if (ninfo != null && ninfo.isConnected()) {

    } else {
      AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
      builder1.setMessage("Sorry There is no internet please check your connection!");
      builder1.setCancelable(true);
      builder1.setPositiveButton(
          "I Will!",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
            }
          });

      AlertDialog alert11 = builder1.create();
      alert11.show();
    }

    itemlist = new ArrayList<RSSItem>();

    new RetrieveRSSFeeds().execute();
  }
 /**
  * Tell the client to display a javascript alert dialog.
  *
  * @param view
  * @param url
  * @param message
  * @param result
  */
 @Override
 public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
   AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx);
   dlg.setMessage(message);
   dlg.setTitle("Alert");
   // Don't let alerts break the back button
   dlg.setCancelable(true);
   dlg.setPositiveButton(
       android.R.string.ok,
       new AlertDialog.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           result.confirm();
         }
       });
   dlg.setOnCancelListener(
       new DialogInterface.OnCancelListener() {
         public void onCancel(DialogInterface dialog) {
           result.confirm();
         }
       });
   dlg.setOnKeyListener(
       new DialogInterface.OnKeyListener() {
         // DO NOTHING
         public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
           if (keyCode == KeyEvent.KEYCODE_BACK) {
             result.confirm();
             return false;
           } else return true;
         }
       });
   dlg.create();
   dlg.show();
   return true;
 }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);
            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else {
            preference.setSummary(stringValue);
          }

          // detect errors
          if (preference.getKey().equals("sos_uri")) {
            try {
              URL url = new URL(value.toString());
              if (!url.getProtocol().equals("http") && !url.getProtocol().equals("https"))
                throw new Exception("SOS URL must be HTTP or HTTPS");
            } catch (Exception e) {
              AlertDialog.Builder dlgAlert = new AlertDialog.Builder(preference.getContext());
              dlgAlert.setMessage("Invalid SOS URL");
              dlgAlert.setTitle(e.getMessage());
              dlgAlert.setPositiveButton("OK", null);
              dlgAlert.setCancelable(true);
              dlgAlert.create().show();
            }
          }

          return true;
        }
  public void onLongItemSelected(int seleccion) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle("Confirmar");
    dialog.setMessage("¿Seguro que quiere borrar la partida?");
    dialog.setIcon(android.R.drawable.ic_dialog_info);

    dialog.setCancelable(false);
    dialog.setPositiveButton(
        "Si",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // Hacer Algo;
            dialog.cancel();
          }
        });
    dialog.setNegativeButton(
        "No",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // Cancelar
            dialog.cancel();
          }
        });

    dialog.show();
  }