public void reportWinner(final Tile.Owner winner) {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    if (winner == Tile.Owner.BOTH) {
      builder.setMessage("It's a TIE!");
    } else {
      builder.setMessage(getString(R.string.declare_winner, winner));
    }
    builder.setCancelable(false);
    builder.setPositiveButton(
        R.string.ok_label,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            finish();
          }
        });
    final Dialog dialog = builder.create();

    Window window = dialog.getWindow();
    window.setGravity(Gravity.TOP);
    dialog.show();

    // Reset the board to the initial position
    mGameFragment.initGame();
  }
Esempio n. 2
0
  // Create the dialog boxes
  @Override
  protected Dialog onCreateDialog(int id) {
    // Create the confirmation dialog
    if (id == CLEAR_CACHE_ALERT) {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setMessage("Delete all images in APOD cache?")
          .setPositiveButton("Yes", clearCacheDialogClickListener)
          .setNegativeButton("No", clearCacheDialogClickListener);

      return builder.create();
    }

    // Create the Done dialog
    if (id == CLEAR_CACHE_ALERT_DONE) {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setMessage("   Done   ")
          .setCancelable(false)
          .setPositiveButton(
              "OK",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  // do things
                }
              });

      return builder.create();
    }
    return null;
  }
 @Override
 public void onClick(View arg0) {
   // TODO Auto-generated method stub
   if (arg0.equals(btnSure)) {
     if (etPasswd.getText().toString().trim().equals("666666")) {
       ly.removeAllViews();
       ly.addView(view);
       bPasswdOk = true;
     } else {
       AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
       b.setMessage(R.string.passwd_error);
       b.setPositiveButton(R.string.btn_sure, null);
       b.show();
     }
   } else if (arg0.equals(btnSaveIP)) {
     editor.putString(CONTROLLER_10_IP, etController10IP.getText().toString().trim());
     editor.putString(CONTROLLER_9_IP, etController9IP.getText().toString().trim());
     editor.putString(CONTROLLER_8_IP, etController8IP.getText().toString().trim());
     editor.putString(CONTROLLER_7_IP, etController7IP.getText().toString().trim());
     editor.putString(CONTROLLER_6_IP, etController6IP.getText().toString().trim());
     editor.putString(CONTROLLER_5_IP, etController5IP.getText().toString().trim());
     editor.putString(CONTROLLER_4_IP, etController4IP.getText().toString().trim());
     editor.putString(CONTROLLER_3_IP, etController3IP.getText().toString().trim());
     editor.putString(CONTROLLER_2_IP, etController2IP.getText().toString().trim());
     editor.putString(CONTROLLER_1_IP, etController1IP.getText().toString().trim());
     editor.commit();
     AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
     b.setMessage(R.string.save_ok);
     b.setPositiveButton(R.string.btn_sure, null);
     b.show();
   }
 }
Esempio n. 4
0
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      // builder.setIcon(R.drawable.alert_dialog_icon)
      builder.setTitle(getArguments().getString(BUNDLE_TITLE));
      if (getArguments().getBoolean(BUNDLE_ISHTML)) {
        builder.setMessage(Html.fromHtml(getArguments().getString(BUNDLE_BODY)));
      } else {
        builder.setMessage(getArguments().getString(BUNDLE_BODY));
      }

      // Create the 'ok' button
      return builder
          .setPositiveButton(
              R.string.alert_dialog_ok,
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                  if (callback != null) {
                    callback.onDialogClose();
                  }
                  closeDialog();
                }
              })
          .create();
    }
  // Esse método trata os retornos
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    Bundle parametros = null;

    if (data != null) parametros = data.getExtras();
    if (requestCode == ExemploParametros) {
      switch (resultCode) {
        case RESULT_OK:
          if (parametros != null) {

            String valor = parametros.getString("VALOR");
            AlertDialog.Builder dlg = new AlertDialog.Builder(this);
            dlg.setMessage("O valor do parametro é: " + valor);
            dlg.setNeutralButton("OK", null);
            dlg.show();
          }

          break;

        case RESULT_CANCELED:
          AlertDialog.Builder dlg = new AlertDialog.Builder(this);
          dlg.setMessage("Operação cancelada");
          dlg.setNeutralButton("OK", null);
          dlg.show();

          break;
      }
    }
  }
  private void verifyBluetooth() {

    try {
      if (!BeaconManager.getInstanceForApplication(getApplicationContext()).checkAvailability()) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
        builder.setTitle("Bluetooth not enabled");
        builder.setMessage("Please enable bluetooth in settings and restart this application.");
        builder.setPositiveButton(android.R.string.ok, null);
        builder.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              @Override
              public void onDismiss(DialogInterface dialog) {
                System.exit(0);
              }
            });
        builder.show();
      }
    } catch (RuntimeException e) {
      final AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
      builder.setTitle("Bluetooth LE not available");
      builder.setMessage("Sorry, this device does not support Bluetooth LE.");
      builder.setPositiveButton(android.R.string.ok, null);
      builder.setOnDismissListener(
          new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
              System.exit(0);
            }
          });
      builder.show();
    }
  }
  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. 8
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;
 }
  private Boolean validarEmprestimo() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setPositiveButton(R.string.ok, null);
    builder.setTitle(R.string.app_name);

    if (ne_desc.getText().toString().isEmpty()) {
      builder.setMessage(R.string.infoDescricao);
      AlertDialog dialog = builder.create();
      dialog.show();
      return false;
    }

    if (ne_nome.getSelectedItem().toString().isEmpty()) {
      builder.setMessage(R.string.infoContato);
      AlertDialog dialog = builder.create();
      dialog.show();
      return false;
    }

    if (ne_data.getText().toString().isEmpty()) {
      builder.setMessage(R.string.infoData);
      AlertDialog dialog = builder.create();
      dialog.show();
      return false;
    }

    return true;
  }
Esempio n. 10
0
  private void showAlert(int alertCase) {
    // prepare the alert box
    AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
    switch (alertCase) {
      case AUTH: // Card Authentication Error
        alertbox.setMessage("Authentication Failed on Block 0");
        break;
      case EMPTY_BLOCK_0: // Block 0 Empty
        alertbox.setMessage("Failed reading Block 0");
        break;
      case EMPTY_BLOCK_1: // Block 1 Empty
        alertbox.setMessage("failed");
        break;
      case NETWORK: // Communication Error
        alertbox.setMessage("Tag reading error");
        break;
    }
    // set a positive/yes button and create a listener
    alertbox.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {

          // Save the data from the UI to the database - already done
          public void onClick(DialogInterface arg0, int arg1) {}
        });
    // display box
    alertbox.show();
  }
Esempio n. 11
0
  /** Create AlertDialogs used on all the activity */
  private void initAllAlertDialogs() {
    Resources res = getResources();

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

    builder.setTitle(res.getString(R.string.connection_error_title));
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setMessage(res.getString(R.string.connection_needed));
    builder.setPositiveButton(res.getString(R.string.ok), null);
    mNoConnectionAlert = builder.create();

    builder.setTitle(res.getString(R.string.log_in));
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setMessage(res.getString(R.string.invalid_username_password));
    mInvalidUserPassAlert = builder.create();

    builder.setTitle(res.getString(R.string.connection_error_title));
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setMessage(res.getString(R.string.connection_error_message));
    builder.setPositiveButton(
        res.getString(R.string.retry),
        new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface dialog, int which) {
            login();
          }
        });
    builder.setNegativeButton(res.getString(R.string.cancel), null);
    mConnectionErrorAlert = builder.create();
  }
        @Override
        public void dispatchMessage(Message msg) {
          AlertDialog.Builder builder = new Builder(activity);
          switch (msg.arg1) {
            case NO_NET:
              popWin.dismiss();
              builder.setMessage("请登录后再进行此操作!");
              builder.setPositiveButton(
                  "确认",
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                    }
                  });
              // builder.create().show();
              break;
            case ADD_SUCCESS:
              popWin.dismiss();
              Courseware courseware = coursewares.get(msg.arg2);
              courseware.setSelfCourse(true);
              PhoneStudyAdapter.this.notifyDataSetChanged();
              builder.setMessage("加入自选课成功 !");
              builder.setPositiveButton(
                  "确认",
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                    }
                  });
              // builder.create().show();
              break;
            case CANCEL_SUCCESS:
              popWin.dismiss();
              Courseware cancelCourseware = coursewares.get(msg.arg2);
              if (cancelCourseware.isSelfPage()) {
                if (allCoursewares != null) allCoursewares.remove(cancelCourseware);
                coursewares.remove(cancelCourseware);
              } else {
                cancelCourseware.setSelfCourse(false);
              }
              PhoneStudyAdapter.this.notifyDataSetChanged();
              builder.setMessage("取消自选课成功 !");
              builder.setPositiveButton(
                  "确认",
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                    }
                  });
              // builder.create().show();
              break;
          }
        }
Esempio n. 13
0
  public void showErrorDialog(int typeOfError) {
    AlertDialog.Builder builder =
        new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_DARK)
            .setTitle(R.string.app_name);
    pd.dismiss();
    switch (typeOfError) {
      case WRONG_INPUT_ERROR:
        {
          builder.setMessage("Username and/or password is incorrect.  Please try again!");
          builder.setPositiveButton(
              "Okay",
              new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                  // reset both fields
                  mUserNameBox.setText("");
                  mPasswordBox.setText("");
                  // shift focus back to user name field
                  mUserNameBox.requestFocus();
                  return;
                }
              });
          break;
        }
      case CONNECTION_ERROR:
        {
          builder.setMessage("Connection failed.  Please check your internet connection.");
          builder.setPositiveButton(
              "Check settings",
              new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
                  startActivity(intent);
                  finishActivity();
                }
              });
          builder.setNegativeButton(
              "Try again",
              new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                  pd.dismiss();
                  login();
                }
              });
          break;
        }
    }
    AlertDialog dialog = builder.create();
    // so dialog doesn't get closed when touched outside of it
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
   AlertDialog helpDialog = null;
   switch (item.getItemId()) {
     case R.id.about:
       helpBuilder.setTitle(getString(string.beercount_2013));
       helpBuilder.setMessage(getString(string.license));
       helpBuilder.setPositiveButton(
           getString(string.ok),
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
               // Do nothing but close the dialog
             }
           });
       helpDialog = helpBuilder.create();
       helpDialog.show();
       return true;
     case R.id.reset:
       helpBuilder.setTitle(getString(string.confirmation));
       helpBuilder.setMessage(getString(string.confirm_erase_local));
       helpBuilder.setPositiveButton(
           getString(string.yes),
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
               try {
                 file.close();
                 tempfile = openFileOutput(FILENAME, Context.MODE_PRIVATE);
                 /* Update beer counts */
                 updateBeerCounts();
                 pintView.setText(getString(R.string.pints, pintCount));
                 bottleView.setText(getString(R.string.bottles, bottleCount));
                 halfView.setText(getString(R.string.halfs, halfCount));
               } catch (IOException e) {
                 e.printStackTrace();
               }
             }
           });
       helpBuilder.setNegativeButton(
           getString(string.no),
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
               // Do nothing but close the dialog
             }
           });
       helpDialog = helpBuilder.create();
       helpDialog.show();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
    @Override
    public void onClick(View v) {

      if (v.getId() == R.id.btnConfirmar) {

        String nome, email, senha, confSenha, cpf, telefone, tipoSocio, sexo, numCartao;

        nome = etNome.getText().toString();
        email = etEmail.getText().toString();
        senha = etSenha.getText().toString();
        confSenha = etConfSenha.getText().toString();
        cpf = etCPF.getText().toString();
        telefone = etTelefone.getText().toString();
        tipoSocio = spTipoSocio.getSelectedItem().toString();
        sexo = spSexo.getSelectedItem().toString();
        numCartao = etNumCartao.getText().toString();

        if (TelaCadastro.isEditar()) {
          Socio socio =
              new Socio(nome, email, senha, confSenha, cpf, telefone, tipoSocio, sexo, 0, 0);
          Banco banco = new Banco(getActivity());
          System.out.println(Socio.getSocioLogado().getEmail());
          banco.editarSocio(socio, banco.usuarioGetId(Socio.getSocioLogado().getEmail()));
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          builder.setMessage("Cadastro Editado com Sucesso").setTitle("Editado");
          AlertDialog dialog = builder.create();
          dialog.show();

          Intent intent = new Intent(getActivity(), TelaLogin.class);
          startActivity(intent);
        } else {
          CartaoDAO cDAO = new CartaoDAO(getActivity());

          if (cDAO.validarCartaoCadastro(numCartao, cpf)) {
            Socio socio =
                new Socio(nome, email, senha, confSenha, cpf, telefone, tipoSocio, sexo, 0, 0);
            SocioDAO banco = new SocioDAO(getActivity());
            banco.cadastrarSocio(socio);
            cDAO.inserirIdSocioCartao(socio);
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage(" Parabéns! Você se associou!").setTitle("Parabéns");
            AlertDialog dialog = builder.create();
            dialog.show();

            Intent intent = new Intent(getActivity(), TelaLogin.class);
            startActivity(intent);
          } else {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage("Cartão inválido ou não pertence ao sócio").setTitle("Inválido");
            AlertDialog dialog = builder.create();
            dialog.show();
          }
        }
      }
    }
  private void addFavorite() {
    // mURL = _mURL;title = _title;delay = _delay;state = _state;
    // create the database manager object
    db = new AABDatabaseManager(getActivity());
    ArrayList<ArrayList<Object>> data = db.getAllRowsAsArrays();
    Boolean found = false;
    // iterate the ArrayList, create new rows each time and add them
    // to the table widget.
    if (data.size() > 999) {
      AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());

      alert.setMessage("Please delete a favorite from the favorites menu before adding more.");

      alert.setPositiveButton(
          "OK",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {}
          });
      alert.show();
    } else {
      for (int position = 0; position < data.size(); position++) {
        ArrayList<Object> row = data.get(position);

        String mCameraName = row.get(1).toString();
        if (mCameraName.equals(mURL)) {
          found = true;
          AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
          alert.setMessage("Camera already exists in favorites");
          alert.setPositiveButton(
              "OK",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {}
              });
          alert.show();
          db.close();
          break;
        }
      }
      if (!found) {
        try {
          db.addRow(mURL, title, delay, state);
          Toast.makeText(
                  getActivity().getApplicationContext(),
                  title + " added to favorites",
                  Toast.LENGTH_LONG)
              .show();

        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      db.close();
    }
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());

    if (resId == 0) {
      builder.setMessage(string);
    } else {
      builder.setMessage(resId);
    }

    this.configureBuilder(builder);
    return builder.create();
  }
 @Override
 public void onPrepareDialogBuilder(AlertDialog.Builder builder) {
   PreyConfig preyConfig = PreyConfig.getPreyConfig(ctx);
   if (preyConfig.isFroyoOrAbove()) {
     if (FroyoSupport.getInstance(ctx).isAdminActive()) {
       builder.setTitle(R.string.preferences_admin_enabled_dialog_title);
       builder.setMessage(R.string.preferences_admin_enabled_dialog_message);
     } else {
       builder.setTitle(R.string.preferences_admin_disabled_dialog_title);
       builder.setMessage(R.string.preferences_admin_disabled_dialog_message);
     }
   }
 }
 public void showNoPGPKeyDialog(boolean plural, DialogInterface.OnClickListener listener) {
   AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
   builder.setIconAttribute(android.R.attr.alertDialogIcon);
   if (plural) {
     builder.setTitle(getString(R.string.no_pgp_keys));
     builder.setMessage(getText(R.string.contacts_have_no_pgp_keys));
   } else {
     builder.setTitle(getString(R.string.no_pgp_key));
     builder.setMessage(getText(R.string.contact_has_no_pgp_key));
   }
   builder.setNegativeButton(getString(R.string.cancel), null);
   builder.setPositiveButton(getString(R.string.send_unencrypted), listener);
   builder.create().show();
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.imdbMenuItem:
       if (this.imdb != null) {
         Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("imdb:///title/" + this.imdb));
         Activity parent = this.getSherlockActivity();
         if (parent != null) {
           try {
             startActivity(intent);
           } catch (Exception e) {
             try {
               Intent market =
                   new Intent(
                       Intent.ACTION_VIEW, Uri.parse("market://details?id=com.imdb.mobile"));
               startActivity(market);
             } catch (Exception e2) {
               if (getSherlockActivity() != null) {
                 AlertDialog.Builder build = new AlertDialog.Builder(getSherlockActivity());
                 build.setMessage(R.string.imdb_view_error);
                 build.setPositiveButton(
                     R.string.ok,
                     new DialogInterface.OnClickListener() {
                       @Override
                       public void onClick(DialogInterface dialog, int which) {
                         dialog.cancel();
                       }
                     });
                 build.show();
               }
             }
           }
         }
       } else {
         AlertDialog.Builder build = new AlertDialog.Builder(getSherlockActivity());
         build.setMessage(R.string.wait_error);
         build.setPositiveButton(
             R.string.ok,
             new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int which) {
                 dialog.cancel();
               }
             });
         build.show();
       }
   }
   return super.onOptionsItemSelected(item);
 }
 /**
  * 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();
   }
 }
Esempio n. 22
0
  /**
   * Function to show settings alert dialog On pressing Settings button will lauch Settings Options
   */
  public void showSettingsAlert() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);

    // Setting Dialog Title
    alertDialog.setTitle("GPS is settings");

    // Setting Dialog Message
    alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");

    // On pressing Settings button
    alertDialog.setPositiveButton(
        "Settings",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
          }
        });

    // on pressing cancel button
    alertDialog.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
          }
        });

    // Showing Alert Message
    alertDialog.show();
  }
Esempio n. 23
0
 private void buildAlertMessageNoGps() {
   final AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder
       .setMessage(" GPS & LOCATIONSERVICE is Required, do you want to enable it?")
       .setCancelable(false)
       .setPositiveButton(
           "Yes",
           new DialogInterface.OnClickListener() {
             public void onClick(
                 @SuppressWarnings("unused") final DialogInterface dialog,
                 @SuppressWarnings("unused") final int id) {
               startActivity(
                   new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
             }
           })
       .setNegativeButton(
           "No",
           new DialogInterface.OnClickListener() {
             public void onClick(
                 final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
               dialog.cancel();
             }
           });
   final AlertDialog alert = builder.create();
   alert.show();
 }
        @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;
        }
Esempio n. 25
0
  public void park(final Activity ctx) {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ctx);
    final String regno = pref("regno", "", ctx);
    final String msg = "Alustan parkimist s›idukile " + regno + " tsoonis " + key;

    alertBuilder
        .setMessage(msg + "?")
        .setCancelable(false)
        .setPositiveButton(
            "Jah",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                String msg = regno + " " + key;
                SmsManager sm = SmsManager.getDefault();
                sm.sendTextMessage("1902", null, msg, null, null);
                send_notification("Parkimine alustatud ", "s›iduk " + regno + " tsoon " + key, ctx);
                set_pref("parking_active", "true", ctx);
                set_pref("start_time", new Long(SystemClock.elapsedRealtime()).toString(), ctx);
                ctx.finish();
              }
            })
        .setNegativeButton(
            "Ei",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
              }
            });

    alertBuilder.create();
    alertBuilder.show();
  }
  @Override
  protected void onProgressUpdate(String... values) {
    super.onProgressUpdate(values);

    // EditText passwordField = (EditText)
    // parent.findViewById(R.id.LoginScreen_EditTextPassword);

    String[] message_parts = values[0].split(":");

    // FORMAT: [TYPE]:[EMAIL]:[TOKEN]:[DATA]:[EOP]
    // 0 1 2 3 4
    Log.v("REC_M", "RECEIVED:" + values[0]);

    if (message_parts.length == 5) {
      String TYPE = message_parts[0];
      String Status = message_parts[3];

      Log.v("TYPE", "TYPE:" + TYPE);

      if (TYPE.equals("STATUS")) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(parent);
        alertDialog.setTitle("             User Alert !");
        alertDialog.setMessage(Status);
        alertDialog.setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {}
            });

        alertDialog.show();
        (parent.findViewById(R.id.ForgotPassword_ButtonResetPassword)).setEnabled(true);
      }
    }
  }
  /**
   * This displays a pop up that asks the user whether they want to add the appointment to their
   * native android calendar. If yes, another method is invoked to do this.
   *
   * @param details all of the details about the appointment
   * @param id the id of the appointment in the database
   */
  private void addToCalendarQuestion(final HashMap<String, String> details, final int id) {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle("Add To Calendar");
    alert.setMessage("Do you want to add this appointment to your phones calendar?");

    alert.setPositiveButton(
        "Yes",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            addToCalendar(details, id);
          }
        });

    alert.setNegativeButton(
        "No",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            finish();
            getIntent();
          }
        });

    alert.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. 29
0
  private void showConfirmDialog(final int monthType) {
    // TODO Auto-generated method stub
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    int[] month = {1, 3, 6, 12};
    int[] money = {11000, 31000, 61000, 110000};

    builder.setMessage("开通" + month[monthType] + "个月会员,需花费" + money[monthType] + "金币");
    builder.setPositiveButton(
        "开通",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            buyVIP(monthType);
          }
        });
    builder.setNegativeButton(
        "取消",
        new DialogInterface.OnClickListener() {

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

          }
        });
    AlertDialog confDialog = builder.create();
    confDialog.show();
  }
Esempio n. 30
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();
  }