List of usage examples for android.app AlertDialog.Builder AlertDialog.Builder
public Builder(Context context)
From source file:org.occupycincy.android.OccupyCincyActivity.java
private void showAlert(String text) { if (alert != null) { alert.dismiss();// w ww.ja v a 2s . c om alert = null; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(text).setCancelable(false).setPositiveButton("Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alert = builder.create(); alert.show(); }
From source file:com.slidinglayersample.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main_menu, menu); menu.findItem(R.id.action_sign_out).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { User.signOutUser();/*w ww . j a va 2s . co m*/ MainActivity.this.finish(); startActivity(new Intent(MainActivity.this, RegisterOrSignInActivity.class)); return true; } }); menu.findItem(R.id.action_new_company).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); final ArrayList<Integer> mSelectedItems = new ArrayList<Integer>(); LayoutInflater inflater = MainActivity.this.getLayoutInflater(); final View v = inflater.inflate(R.layout.dialog_create_company, null, false); builder.setView(v); builder.setTitle("Add company"); builder.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Company c = new Company(); EditText name = (EditText) v.findViewById(R.id.reg_company_name); EditText desc = (EditText) v.findViewById(R.id.reg_company_description); c.setName(name.getText().toString()); c.setDescription(desc.getText().toString()); c.setCreatorId(User.getCurrentUser().getId()); // mCompanyArrayList.add(c); // mCompanyAdapter.notifyDataSetChanged(); dlg = new ProgressDialog(MainActivity.this); dlg.setTitle("Please wait."); dlg.setMessage("Company registration. Please wait."); dlg.show(); new RegisterCompany().execute(c); // showToast("Added company : " + c.getName(), SuperToast.Background.BLUE); // Toast.makeText(getApplicationContext(), mSelectedItems.size(), Toast.LENGTH_LONG).show(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); AlertDialog dialog = builder.create(); dialog.show(); return true; } }); return true; }
From source file:de.NeonSoft.neopowermenu.Preferences.PreferencesPartFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO: Implement this method MainActivity.visibleFragment = "Main"; mContext = getActivity();/* w ww . ja v a 2 s.com*/ ActiveStyle = MainActivity.preferences.getString("DialogTheme", "Material"); hideicon = MainActivity.preferences.getBoolean("HideLauncherIcon", false); DeepXposedLogging = MainActivity.preferences.getBoolean("DeepXposedLogging", false); InflatedView = inflater.inflate(R.layout.activity_preferences, container, false); TextView_ModuleStateTitle = (TextView) InflatedView .findViewById(R.id.activitypreferencesTextView_ModuleStateTitle); TextView_ModuleStateDesc = (TextView) InflatedView .findViewById(R.id.activitypreferencesTextView_ModuleStateDesc); LinearLayout_Style = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Style); TextView_StyleTitle = (TextView) InflatedView.findViewById(R.id.activitypreferencesTextView_StyleTitle); TextView_StyleDesc = (TextView) InflatedView.findViewById(R.id.activitypreferencesTextView_StyleDesc); TextView_StyleDesc.setText(getString(R.string.preferencesDesc_Style).replace("[STYLENAME]", ActiveStyle)); LinearLayout_Theme = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Theme); LinearLayout_VisibilityOrder = (LinearLayout) InflatedView .findViewById(R.id.activitypreferencesLinearLayout_VisibilityOrder); LinearLayout_Advanced = (LinearLayout) InflatedView .findViewById(R.id.activitypreferencesLinearLayout_Advanced); LinearLayout_HideLauncherIcon = (LinearLayout) InflatedView .findViewById(R.id.activitypreferencesLinearLayout_HideLauncherIcon); Switch_HideLauncherIcon = (Switch) InflatedView .findViewById(R.id.activitypreferencesSwitch_HideLauncherIcon); Switch_HideLauncherIcon.setChecked(hideicon); Switch_HideLauncherIcon.setClickable(false); Switch_HideLauncherIcon.setFocusable(false); LinearLayout_DeepXposedLogging = (LinearLayout) InflatedView .findViewById(R.id.activitypreferencesLinearLayout_DeepXposedLogging); Switch_DeepXposedLogging = (Switch) InflatedView .findViewById(R.id.activitypreferencesSwitch_DeepXposedLogging); Switch_DeepXposedLogging.setChecked(DeepXposedLogging); Switch_DeepXposedLogging.setClickable(false); Switch_DeepXposedLogging.setFocusable(false); LinearLayout_Source = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Source); LinearLayout_OrigSource = (LinearLayout) InflatedView .findViewById(R.id.activitypreferencesLinearLayout_OrigSource); LinearLayout_Share = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Share); LinearLayout_Translator = (LinearLayout) InflatedView .findViewById(R.id.activitypreferencesLinearLayout_Translator); LinearLayout_About = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_About); LinearLayout_Style.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { // TODO: Implement this method AlertDialog.Builder alertdb = new AlertDialog.Builder(getActivity()); alertdb.setTitle(R.string.preferencesTitle_Style); String[] styleList = new String[1]; styleList[0] = "Material"; for (int i = 0; i < styleList.length; i++) { if (styleList[i].equalsIgnoreCase(ActiveStyle)) { ActiveStyleId = i; //presetsList[i] = "(Active) "+ presetsFiles[i].getName().split(".nps")[0]; } } alertdb.setSingleChoiceItems(styleList, ActiveStyleId, null); alertdb.setNegativeButton(R.string.Dialog_Cancel, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { // TODO: Implement this method } }); alertdb.setPositiveButton(R.string.Dialog_Ok, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { // TODO: Implement this method try { int selectedPosition = (ad).getListView().getCheckedItemPosition(); String selectedName = (ad).getListView().getItemAtPosition(selectedPosition).toString(); MainActivity.preferences.edit().putString("DialogTheme", selectedName).commit(); ActiveStyle = selectedName; TextView_StyleDesc.setText( getString(R.string.preferencesDesc_Style).replace("[STYLENAME]", ActiveStyle)); } catch (Throwable t) { } } }); ad = alertdb.create(); ad.show(); } }); LinearLayout_Theme.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { MainActivity.fragmentManager.beginTransaction() .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .replace(R.id.pref_container, new PreferencesColorFragment()).commit(); } }); LinearLayout_VisibilityOrder.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { MainActivity.fragmentManager.beginTransaction() .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .replace(R.id.pref_container, new PreferencesVisibilityOrderFragment()).commit(); } }); LinearLayout_Advanced.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { MainActivity.fragmentManager.beginTransaction() .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .replace(R.id.pref_container, new PreferencesAdvancedFragment()).commit(); } }); LinearLayout_HideLauncherIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { hideicon = !hideicon; String packageName = getActivity().getPackageName(); ComponentName componentSettings = new ComponentName(packageName, packageName + ".SettingsActivity"); if (hideicon) { getActivity().getPackageManager().setComponentEnabledSetting(componentSettings, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } else { getActivity().getPackageManager().setComponentEnabledSetting(componentSettings, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } Switch_HideLauncherIcon.setChecked(hideicon); MainActivity.preferences.edit().putBoolean("HideLauncherIcon", hideicon).commit(); } }); LinearLayout_DeepXposedLogging.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { DeepXposedLogging = !DeepXposedLogging; Switch_DeepXposedLogging.setChecked(DeepXposedLogging); MainActivity.preferences.edit().putBoolean("DeepXposedLogging", DeepXposedLogging).commit(); } }); LinearLayout_Source.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { // TODO: Implement this method Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(Urlgithub)); startActivity(i); } }); LinearLayout_OrigSource.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { // TODO: Implement this method Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(Urloriggithub)); startActivity(i); } }); LinearLayout_Share.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { // TODO: Implement this method Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); String sAux = getString(R.string.ShareMessage); sAux = sAux + "repo.xposed.info/module/de.NeonSoft.neopowermenu \n\n"; i.putExtra(Intent.EXTRA_TEXT, sAux); startActivity(Intent.createChooser(i, getString(R.string.preferencesTitle_Share))); } }); LinearLayout_About.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { // TODO: Implement this method adb = new AlertDialog.Builder(getActivity()); adb.setTitle("About"); adb.setMessage("NeoPowerMenu by Neon-Soft / DrAcHe981\n" + "based on a Source from Naman Dwivedi (naman14)\n\n" + "< Used Librarys >\n" + "> HoloColorPicker from Lars Werkman\n" + "An Android Holo themed colorpicker designed by Marie Schweiz\n\n" + "Licensed under the Apache License, Version 2.0\n\n" + "> DragSortListView from Bauerca\n" + "DragSortListView (DSLV) is an extension of the Android ListView that enables drag-and-drop reordering of list items.\n\n" + "Licensed under the Apache License, Version 2.0\n\n" + "> libsuperuser from Chainfire / ChainsDD\n\n" + "Licensed under the Apache License, Version 2.0\n\n" + ""); adb.setPositiveButton(R.string.Dialog_Ok, null); ad = adb.create(); ad.show(); } }); checkState(); if (!MainActivity.RootAvailable) { pd = new ProgressDialog(getActivity()); pd.setMessage(getString(R.string.Dialog_WaitForRoot)); pd.setIndeterminate(true); pd.setCancelable(false); pd.setCanceledOnTouchOutside(false); pd.setButton(pd.BUTTON_NEGATIVE, getString(R.string.Dialog_Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { pd.dismiss(); getActivity().finish(); } }); pd.setButton(pd.BUTTON_NEUTRAL, getString(R.string.Dialog_Ignore), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { pd.dismiss(); } }); pd.show(); } else if (MainActivity.RootAvailable) { rootAvailable(); } getPermissions(); return InflatedView; }
From source file:net.alchemiestick.katana.winehqappdb.SearchView.java
private Dialog about_dialog() { String msg = "Copyright May 25th 2012 by Rene Kjellerup (aka Katana Steel) and Alchemiestick.\n\n"; msg += "WineHQ Appdb Search is released under GPLv3 or later. It uses images from WINE project under LGPLv2 or later "; msg += "see license:\nhttp://www.gnu.org/licenses/\nfor more infomation about the licenses.\n\n"; msg += "Souce code for the program can be obtained at\nhttps://github.com/Katana-Steel/winehqappdb\nand choose "; msg += "the apropriate release tag for the the version you are running."; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("About").setMessage(msg).setCancelable(true).setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();/* w ww . java 2 s . co m*/ } }); return builder.create(); }
From source file:org.jitsi.service.osgi.OSGiActivity.java
/** * Checks if the crash has occurred since the Jitsi was last started. * If it's true asks the user about eventual logs report. *///from w w w. j av a 2 s . c om private void checkForSendLogsDialog() { // Checks if Jitsi has previously crashed and asks the user user // about log reporting if (!ExceptionHandler.hasCrashed()) { return; } // Clears the crash status ExceptionHandler.resetCrashedStatus(); // Asks the user AlertDialog.Builder question = new AlertDialog.Builder(this); question.setTitle(R.string.service_gui_WARNING) .setMessage(getString(R.string.service_gui_SEND_LOGS_QUESTION)) .setPositiveButton(R.string.service_gui_YES, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); JitsiApplication.showSendLogsDialog(); } }).setNegativeButton(R.string.service_gui_NO, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); }
From source file:se.leap.bitmaskclient.Dashboard.java
private void configErrorDialog() { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getContext()); alertBuilder.setTitle(getResources().getString(R.string.setup_error_title)); alertBuilder.setMessage(getResources().getString(R.string.setup_error_text)).setCancelable(false) .setPositiveButton(getResources().getString(R.string.setup_error_configure_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivityForResult(new Intent(getContext(), ConfigurationWizard.class), CONFIGURE_LEAP); }//from ww w . j av a 2 s.c o m }) .setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_CONFIGURED) .apply(); finish(); } }) .show(); }
From source file:com.readystatesoftware.ghostlog.GhostLogSettingsFragment.java
private void processRootFail() { int failCount = mPrefs.getInt(getString(R.string.pref_root_fail_count), 0); if (failCount == 0) { // show dialog first time AlertDialog dlg = new AlertDialog.Builder(mContext).setTitle(R.string.no_root) .setMessage(R.string.no_root_dialog) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // ok, do nothing }// w ww. j a v a2s . c o m }).setNeutralButton(getString(R.string.github), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.repo_url))); startActivity(intent); } }).create(); dlg.show(); mPrefs.edit().putInt(getString(R.string.pref_root_fail_count), failCount + 1).apply(); } else if (failCount <= 3) { // show toast 3 more times Toast.makeText(mContext, R.string.toast_no_root, Toast.LENGTH_LONG).show(); mPrefs.edit().putInt(getString(R.string.pref_root_fail_count), failCount + 1).apply(); } }
From source file:no.digipost.android.gui.MainContentActivity.java
private void showTips() { if (SharedPreferencesUtilities.shouldDisplayScreenlockTips(this) && !TokenEncryption.screenLockEnabled(this) && !TokenStore.onlyLoggedInWithIDporten4()) { new AlertDialog.Builder(this).setTitle(getString(R.string.screenlock_tips_title)) .setMessage(getString(R.string.screenlock_tips_message)) .setPositiveButton(getString(R.string.screenlock_show_tips), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(MainContentActivity.this, ScreenlockPreferenceActivity.class); startActivity(intent); }/*from w w w.j av a2 s . co m*/ }) .setNegativeButton(getString(R.string.screenlock_hide_tips), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { SharedPreferencesUtilities.hideScreenlockTips(getApplicationContext()); } }) .show(); } if (TokenStore.onlyLoggedInWithIDporten4() && SharedPreferencesUtilities.shouldDisplayIDPortenTips(this)) { new AlertDialog.Builder(this).setTitle(getString(R.string.idporten_tips_title)) .setMessage(getString(R.string.idporten_tips_message)).setPositiveButton( getString(R.string.idporten_tips_ok_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferencesUtilities.hideIDPortenTips(getApplicationContext()); } }) .show(); } }
From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java
public boolean checkStackTrace() { FileInputStream traceIn = null; try {/*from ww w . ja v a2 s. c om*/ traceIn = openFileInput("stack.trace"); traceIn.close(); } catch (FileNotFoundException fnfe) { // No stack trace available return false; } catch (IOException ioe) { return false; } AlertDialog alert = new AlertDialog.Builder(this).create(); alert.setMessage(getResources().getString(R.string.crashreport_msg)); alert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.emailstr), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String trace = ""; String line = null; try { BufferedReader reader = new BufferedReader( new InputStreamReader(TwitSpeakActivity.this.openFileInput("stack.trace"))); while ((line = reader.readLine()) != null) { trace += line + "\n"; } } catch (FileNotFoundException fnfe) { Log.logException(TAG, fnfe); } catch (IOException ioe) { Log.logException(TAG, ioe); } Intent sendIntent = new Intent(Intent.ACTION_SEND); String subject = "Error report"; String body = getResources().getString(R.string.mailthisto_msg) + " jayesh@altcanvas.com: " + "\n\n" + G.getPhoneInfo() + "\n\n" + "TwitSpeak [" + G.VERSION_STRING + "]" + "\n\n" + trace + "\n\n"; sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jayesh@altcanvas.com" }); sendIntent.putExtra(Intent.EXTRA_TEXT, body); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.setType("message/rfc822"); TwitSpeakActivity.this.startActivityForResult( Intent.createChooser(sendIntent, getResources().getString(R.string.emailstr)), G.REQCODE_EMAIL_STACK_TRACE); TwitSpeakActivity.this.deleteFile("stack.trace"); } }); alert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancelstr), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { TwitSpeakActivity.this.deleteFile("stack.trace"); TwitSpeakActivity.this.continueOnCreate(); } }); alert.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { TwitSpeakActivity.this.deleteFile("stack.trace"); TwitSpeakActivity.this.continueOnCreate(); } }); alert.show(); return true; }
From source file:mx.klozz.xperience.tweaker.fragments.VoltageControlSettings.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.tablist: Helpers.getTabList(getString(R.string.menu_tab), (ViewPager) getView().getParent(), getActivity()); break;/*from w w w .jav a2 s .c om*/ case R.id.app_settings: Intent intent = new Intent(context, Settings.class); startActivity(intent); break; case R.id.volt_increase: IncreasebyStep(mstep); break; case R.id.volt_decrease: IncreasebyStep(-1 * mstep); break; case R.id.reset: new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.mt_reset)) .setMessage(getString(R.string.reset_msg)) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ResetVolt(); } }).create().show(); break; } return true; }