List of usage examples for android.app AlertDialog show
public void show()
From source file:org.thomasamsler.android.flashcards.fragment.CardSetsFragment.java
private void deleteCardSet(final int listItemPosition) { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setMessage(R.string.delete_card_set_dialog_message); builder.setCancelable(false);// w w w . j a v a2 s . com builder.setPositiveButton(R.string.delete_card_set_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { CardSet cardSet = mCardSets.get(listItemPosition); List<CardSet> cardSets = mDataSource.getCardSets(); if (cardSets.contains(cardSet)) { mDataSource.deleteCardSet(cardSet); } mCardSets.remove(listItemPosition); Collections.sort(mCardSets); mArrayAdapter.notifyDataSetChanged(); } }); builder.setNegativeButton(R.string.delete_card_set_dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.abc.driver.TruckActivity.java
/** * edit portait// w w w.j a v a 2 s. com * * @param v */ public void editDriverLicense(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(res.getString(R.string.choose_portrait)); builder.setItems(new String[] { res.getString(R.string.getPhotoFromCamera), res.getString(R.string.getPhotoFromMemory) }, new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int id) { switch (id) { case 0: startToCameraActivity(CellSiteConstants.TAKE_PICTURE); break; case 1: startToMediaActivity(CellSiteConstants.PICK_PICTURE); break; } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.abc.driver.TruckActivity.java
/** * edit portait/* w ww . j a v a 2 s .co m*/ * * @param v */ public void editPhotoImage(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(res.getString(R.string.choose_portrait)); builder.setItems(new String[] { res.getString(R.string.getPhotoFromCamera), res.getString(R.string.getPhotoFromMemory) }, new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int id) { switch (id) { case 0: startToCameraActivity(CellSiteConstants.TAKE_PICTURE2); break; case 1: startToMediaActivity(CellSiteConstants.PICK_PICTURE2); break; } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.swissbit.homeautomation.asyncTask.AuthenticationAsync.java
/** *Show the dialog message after the RaspberryPi authentication *///from w w w . j av a 2 s. com public void showDialog() { AlertDialog alertDialog = new AlertDialog.Builder(mainActivityContext).create(); alertDialog.setTitle("Information"); alertDialog.setMessage(dialogMessage); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (subscriptionResponse) mainActivity.checkRaspberryId(rid); dialog.dismiss(); cancel(true); } }); alertDialog.show(); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
@Override public void onUpdateCheckCompleted(UpdateManager manager, final Update update) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); if (update.forceExit) { builder.setTitle(R.string.service_is_not_available); } else if (update.forceUpdate) { builder.setTitle(R.string.update_required); } else {/*from w ww.j a v a2 s .c o m*/ builder.setTitle(R.string.update_found); } final View dialogContentsView = createUpdatesFoundDialogContentsView(update); builder.setView(dialogContentsView); initializeUpdatesFoundDialogButtons(builder, update); builder.setCancelable(false); final AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:app.sunstreak.yourpisd.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login_new); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);/*from w w w.j a v a 2s . c om*/ } final SharedPreferences sharedPrefs = getPreferences(Context.MODE_PRIVATE); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); height = size.y; mLoginFormView = findViewById(R.id.login_form); mLoginStatusView = (LinearLayout) findViewById(R.id.login_status); mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message); if (DateHelper.isAprilFools()) { LinearLayout container = (LinearLayout) mLoginFormView.findViewById(R.id.container); ImageView logo = (ImageView) container.findViewById(R.id.logo); InputStream is; try { is = getAssets().open("doge.png"); logo.setImageBitmap(BitmapFactory.decodeStream(is)); is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } mAutoLogin = sharedPrefs.getBoolean("auto_login", false); System.out.println(mAutoLogin); session = ((YPApplication) getApplication()).session; try { boolean refresh = getIntent().getExtras().getBoolean("Refresh"); if (refresh) { mEmail = session.getUsername(); mPassword = session.getPassword(); showProgress(true); mAuthTask = new UserLoginTask(); mAuthTask.execute((Void) null); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0); } else mLoginFormView.setVisibility(View.VISIBLE); } catch (NullPointerException e) { // Keep going. } if (sharedPrefs.getBoolean("patched", false)) { SharedPreferences.Editor editor = sharedPrefs.edit(); editor.remove("password"); editor.putBoolean("patched", true); editor.commit(); } if (!sharedPrefs.getBoolean("AcceptedUserAgreement", false)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getResources().getString(R.string.user_agreement_title)); builder.setMessage(getResources().getString(R.string.user_agreement)); // Setting Positive "Yes" Button builder.setPositiveButton("Agree", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sharedPrefs.edit().putBoolean("AcceptedUserAgreement", true).commit(); dialog.cancel(); } }); // Setting Negative "NO" Button builder.setNegativeButton("Disagree", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event sharedPrefs.edit().putBoolean("AcceptedUserAgreement", false).commit(); Toast.makeText(LoginActivity.this, "Quitting app", Toast.LENGTH_SHORT).show(); finish(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } // Set up the remember_password CheckBox mRememberPasswordCheckBox = (CheckBox) findViewById(R.id.remember_password); mRememberPasswordCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mRememberPassword = isChecked; } }); mRememberPassword = sharedPrefs.getBoolean("remember_password", false); mRememberPasswordCheckBox.setChecked(mRememberPassword); // Set up the auto_login CheckBox mAutoLoginCheckBox = (CheckBox) findViewById(R.id.auto_login); mAutoLoginCheckBox.setChecked(mAutoLogin); mAutoLoginCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton button, boolean isChecked) { mAutoLogin = isChecked; if (isChecked) { mRememberPasswordCheckBox.setChecked(true); } } }); // Set up the login form. mEmailView = (EditText) findViewById(R.id.email); mPasswordView = (EditText) findViewById(R.id.password); mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { if (id == R.id.login || id == EditorInfo.IME_NULL) { attemptLogin(); return true; } return false; } }); //Load stored username/password mEmailView.setText(sharedPrefs.getString("email", mEmail)); mPasswordView.setText(new String(Base64.decode(sharedPrefs.getString("e_password", ""), Base64.DEFAULT))); // If the password was not saved, give focus to the password. if (mPasswordView.getText().equals("")) mPasswordView.requestFocus(); mLoginFormView = findViewById(R.id.login_form); mLoginStatusView = (LinearLayout) findViewById(R.id.login_status); mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message); findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { attemptLogin(); } }); findViewById(R.id.sign_in_button).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0); return false; } }); mLoginFormView.setVisibility(View.VISIBLE); // Login if auto-login is checked. if (mAutoLogin) attemptLogin(); }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
private void addNarrative() { // add a narrative by not passing a parent id - new narrative is created in FrameEditorActivity if (NarrativesManager.getTemplatesCount(getContentResolver()) > 0) { final CharSequence[] items = { getString(R.string.add_blank), getString(R.string.add_template) }; AlertDialog.Builder builder = new AlertDialog.Builder(NarrativeBrowserActivity.this); builder.setTitle(R.string.title_add); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setNegativeButton(android.R.string.cancel, null); builder.setItems(items, new DialogInterface.OnClickListener() { @Override/*from w ww.java 2 s.co m*/ public void onClick(DialogInterface dialog, int item) { mNarratives.setSelectionFromTop(0, 0); // so that the new narrative is visible switch (item) { case 0: final Intent frameEditorIntent = new Intent(NarrativeBrowserActivity.this, FrameEditorActivity.class); startActivityForResult(frameEditorIntent, MediaPhone.R_id_intent_frame_editor); break; case 1: final Intent templateBrowserIntent = new Intent(NarrativeBrowserActivity.this, TemplateBrowserActivity.class); startActivityForResult(templateBrowserIntent, MediaPhone.R_id_intent_template_browser); break; } dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); } else { final Intent frameEditorIntent = new Intent(NarrativeBrowserActivity.this, FrameEditorActivity.class); startActivityForResult(frameEditorIntent, MediaPhone.R_id_intent_frame_editor); } }
From source file:gr.scify.newsum.ui.SearchViewActivity.java
private void Copy() { // TextView tx = (TextView) findViewById(R.id.textView1); TextView title = (TextView) findViewById(R.id.title); String sdtitle = title.getText().toString(); // String copytext = tx.getText().toString(); String alphaAndDigits = sdtitle.replaceAll("[^\\p{L}\\p{N}]", " "); Boolean isSDPresent = android.os.Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED); // track the copy to SD button if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Save to SD", alphaAndDigits, 0l); }/* w w w . j a va 2s . c o m*/ if (isSDPresent) { File folder = new File(Environment.getExternalStorageDirectory() + "/NewSum"); boolean success = false; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { // Do something on success } else { // Do something else on failure } File logFile = new File(folder, alphaAndDigits + ".txt"); // File logFile = new // File(Environment.getExternalStorageDirectory().toString(), // alphaAndDigits+".txt"); if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } BufferedWriter output = null; try { output = new BufferedWriter(new FileWriter(logFile)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { output.write(pText); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { output.close(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.save_massage); builder.setMessage(logFile.getPath()); builder.setPositiveButton(getResources().getText(R.string.ok).toString(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog a = builder.create(); a.show(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast.makeText(SearchViewActivity.this, R.string.check_sd, Toast.LENGTH_SHORT).show(); } }
From source file:mp.paschalis.RequestActivity.java
/** * Replies to request of user/* w w w.j av a 2 s.co m*/ */ private void hButtonReplyRequest() { buttonHybrid.setText(R.string.reply); buttonHybrid.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(RequestActivity.this); builder.setIcon(R.drawable.ic_menu_info_details); builder.setTitle(R.string.replyToRequest); builder.setItems(R.array.ArrayRequestReply, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { LentBookActivity.DataClassLentABook d = new LentBookActivity.DataClassLentABook(); d.destinationUser = dataClassActivities.username; d.isbn = dataClassActivities.book.isbn; d.answer = "0"; if (item == 0) d.answer = "1"; new AsyncTaskReplyToRequest().execute(d); } }); AlertDialog alert = builder.create(); alert.show(); } }); }