List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:com.google.zxing.client.android.result.ResultHandler.java
final void openGoogleShopper(String query) { // Construct Intent to launch Shopper Intent intent = new Intent(Intent.ACTION_SEARCH); intent.setClassName(GOOGLE_SHOPPER_PACKAGE, GOOGLE_SHOPPER_ACTIVITY); intent.putExtra(SearchManager.QUERY, query); // Is it available? PackageManager pm = activity.getPackageManager(); Collection<?> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (availableApps != null && !availableApps.isEmpty()) { // If something can handle it, start it activity.startActivity(intent);//from w w w . j a v a 2 s.c o m } else { // Otherwise offer to install it from Market. AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.msg_google_shopper_missing); builder.setMessage(R.string.msg_install_google_shopper); builder.setIcon(R.drawable.shopper_icon); builder.setPositiveButton(R.string.button_ok, shopperMarketListener); builder.setNegativeButton(R.string.button_cancel, null); builder.show(); } }
From source file:com.irccloud.android.activity.PastebinsActivity.java
public void onIRCEvent(int what, Object o) { IRCCloudJSONObject obj;/*from w ww. j av a 2 s . c o m*/ switch (what) { case NetworkConnection.EVENT_SUCCESS: obj = (IRCCloudJSONObject) o; if (obj.getInt("_reqid") == reqid) { Log.d("IRCCloud", "Pastebin deleted successfully"); reqid = -1; runOnUiThread(new Runnable() { @Override public void run() { adapter.pastebins.remove(pasteToDelete); adapter.notifyDataSetChanged(); checkEmpty(); pasteToDelete = null; } }); } break; case NetworkConnection.EVENT_FAILURE_MSG: obj = (IRCCloudJSONObject) o; if (reqid != -1 && obj.getInt("_reqid") == reqid) { Crashlytics.log(Log.ERROR, "IRCCloud", "Delete failed: " + obj.toString()); reqid = -1; runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(PastebinsActivity.this); builder.setTitle("Error"); builder.setMessage("Unable to delete this pastebin. Please try again shortly."); builder.setPositiveButton("Close", null); builder.show(); } }); } break; default: break; } }
From source file:com.otaupdater.OTAUpdaterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getApplicationContext(); cfg = Config.getInstance(context);/*from www. ja v a 2 s .c om*/ if (!cfg.hasProKey()) { bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), billingSrvConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { billingSrvConn = null; } @Override public void onServiceConnected(ComponentName name, IBinder binder) { IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder); try { Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null); ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); ArrayList<String> ownedItemData = owned .getStringArrayList("INAPP_PURCHASE_DATA_LIST"); if (ownedItems != null && ownedItemData != null) { for (int q = 0; q < ownedItems.size(); q++) { if (ownedItems.get(q).equals(Config.PROKEY_SKU)) { JSONObject itemData = new JSONObject(ownedItemData.get(q)); cfg.setKeyPurchaseToken(itemData.getString("purchaseToken")); break; } } } } catch (RemoteException ignored) { } catch (JSONException e) { e.printStackTrace(); } unbindService(this); billingSrvConn = null; } }, Context.BIND_AUTO_CREATE); } boolean data = Utils.dataAvailable(this); boolean wifi = Utils.wifiConnected(this); if (!data || !wifi) { final boolean nodata = !data && !wifi; if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title); builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivity(i); } }); builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (nodata) { cfg.setIgnoredDataWarn(true); } else { cfg.setIgnoredWifiWarn(true); } dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } } Utils.updateDeviceRegistration(this); CheckinReceiver.setDailyAlarm(this); if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_unsupported_title); builder.setMessage(R.string.alert_unsupported_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { cfg.setIgnoredUnsupportedWarn(true); dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } setContentView(R.layout.main); Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads); if (adFragment != null) getFragmentManager().beginTransaction().hide(adFragment).commit(); ViewPager mViewPager = (ViewPager) findViewById(R.id.pager); bar = getActionBar(); assert bar != null; bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setTitle(R.string.app_name); TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class); ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom); if (cfg.hasStoredRomUpdate()) romTab.setIcon(R.drawable.ic_action_warning); romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class); ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel); if (cfg.hasStoredKernelUpdate()) kernelTab.setIcon(R.drawable.ic_action_warning); kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class); if (!handleNotifAction(getIntent())) { if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) { cfg.getStoredRomUpdate().showUpdateNotif(this); } if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) { cfg.getStoredKernelUpdate().showUpdateNotif(this); } if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0)); } } }
From source file:net.reichholf.dreamdroid.activities.MovieListActivity.java
@Override protected Dialog onCreateDialog(int id) { final Dialog dialog; AlertDialog.Builder builder; switch (id) { case (DIALOG_DELETE_MOVIE_CONFIRM_ID): builder = new AlertDialog.Builder(this); builder.setTitle(mMovie.getString(Movie.TITLE)).setMessage(getText(R.string.delete_confirm)) .setCancelable(false)//from w w w . j a v a 2 s .c o m .setPositiveButton(getText(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { deleteMovie(); dialog.dismiss(); } }).setNegativeButton(getText(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); removeDialog(DIALOG_PICK_LOCATION_ID); } }); dialog = builder.create(); break; case (DIALOG_PICK_LOCATION_ID): CharSequence[] locations = new CharSequence[DreamDroid.LOCATIONS.size()]; int selectedIndex = 0; int lc = 0; for (String location : DreamDroid.LOCATIONS) { locations[lc] = location; if (location.equals(mCurrentLocation)) { selectedIndex = lc; } lc++; } builder = new AlertDialog.Builder(this); builder.setTitle(getText(R.string.choose_location)); builder.setSingleChoiceItems(locations, selectedIndex, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String selectedLoc = DreamDroid.LOCATIONS.get(which); if (!selectedLoc.equals(mCurrentLocation)) { mCurrentLocation = DreamDroid.LOCATIONS.get(which); reload(); } dialog.dismiss(); } }); dialog = builder.create(); break; case (DIALOG_PICK_TAGS_ID): CharSequence[] tags = new CharSequence[DreamDroid.TAGS.size()]; boolean[] selectedTags = new boolean[DreamDroid.TAGS.size()]; int tc = 0; for (String tag : DreamDroid.TAGS) { tags[tc] = tag; if (mSelectedTags.contains(tag)) { selectedTags[tc] = true; } else { selectedTags[tc] = false; } tc++; } mTagsChanged = false; mOldTags = new ArrayList<String>(); mOldTags.addAll(mSelectedTags); builder = new AlertDialog.Builder(this); builder.setTitle(getText(R.string.choose_tags)); builder.setMultiChoiceItems(tags, selectedTags, new OnMultiChoiceClickListener() { /* * (non-Javadoc) * * @see android.content.DialogInterface. * OnMultiChoiceClickListener * #onClick(android.content.DialogInterface, int, boolean) */ @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { String tag = DreamDroid.TAGS.get(which); mTagsChanged = true; if (isChecked) { if (!mSelectedTags.contains(tag)) { mSelectedTags.add(tag); } } else { int idx = mSelectedTags.indexOf(tag); if (idx >= 0) { mSelectedTags.remove(idx); } } } }); builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mTagsChanged) { reload(); } dialog.dismiss(); removeDialog(DIALOG_PICK_TAGS_ID); } }); builder.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mSelectedTags.clear(); mSelectedTags.addAll(mOldTags); dialog.dismiss(); removeDialog(DIALOG_PICK_TAGS_ID); } }); dialog = builder.create(); break; default: dialog = super.onCreateDialog(id); } return dialog; }
From source file:se.anyro.tagtider.TransferActivity.java
private AlertDialog createC2dmDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.c2dm_dialog_title); builder.setMessage(R.string.c2dm_dialog_message); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override/*w w w .j av a 2 s. co m*/ public void onClick(DialogInterface dialog, int which) { if (mRegistrationId == null) { registerC2dm(); } else { new StartSubscriptionTask().execute(mRegistrationId, TYPE_AC2DM); } } }); builder.setNegativeButton("Avbryt", null); final AlertDialog smsDialog = builder.create(); return smsDialog; }
From source file:com.umeng.message.example.MainActivity.java
/** * /*from w w w. j av a 2 s . co m*/ * @param view */ public void upload(View view) { List<Map<String, Object>> all = pushDao.getAll(); if (all.size() == 0) { Toast.makeText(this, "?", Toast.LENGTH_SHORT).show(); return; } // ?? final android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this); builder.setTitle("Upload"); builder.setMessage(""); builder.setCancelable(false); builder.setNegativeButton("", null); // final Button btn = (Button) view; btn.setText("uploading ..."); btn.setClickable(false); RequestParams params = new RequestParams(); params.put("act", "upload_push_msg"); params.put("data", gson.toJson(all)); Log.e("jsondata", gson.toJson(all)); new AsyncHttpClient().post("http://cms.orenda.com.cn:29055/upload_data", params, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); String hasErrors = getString(response, "hasErrors"); if ("false".equals(hasErrors)) { builder.setMessage("?"); pushDao.clear(); } else { String msg = getString(response, "message"); Log.e("upload.hasError=true", msg); builder.setMessage(msg); } btn.setText("UPLOAD"); btn.setClickable(true); builder.show(); } @Override public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { super.onFailure(statusCode, headers, responseString, throwable); Log.e("onFailure1", String.valueOf(responseString) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); Log.e("onFailure2", String.valueOf(errorResponse) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); Log.e("onFailure3", String.valueOf(errorResponse) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } }); }
From source file:cm.aptoide.pt.ManageRepo.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { LayoutInflater li = LayoutInflater.from(this); switch (item.getItemId()) { case ADD_REPO: View view = li.inflate(R.layout.addrepo, null); final TextView sec_msg = (TextView) view.findViewById(R.id.sec_msg); final TextView sec_msg2 = (TextView) view.findViewById(R.id.sec_msg2); final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); }/*from w w w . j av a2 s.co m*/ } }); Builder p = new AlertDialog.Builder(this).setView(view); alrt = p.create(); alrt.setIcon(android.R.drawable.ic_menu_add); alrt.setTitle("Add new repository"); alrt.setButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Message msg = new Message(); EditText uri = (EditText) alrt.findViewById(R.id.edit_uri); String uri_str = uri.getText().toString(); sec_msg.setVisibility(View.GONE); sec_msg2.setVisibility(View.GONE); if (sec.isChecked()) { String user = sec_user.getText().toString(); String pwd = sec_pwd.getText().toString(); int result = checkServer(uri_str, user, pwd); if (result == 200) { msg.obj = 0; db.addServer(uri_str); db.addLogin(user, pwd, uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login is wrong"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } else { int result = checkServer(uri_str, null, null); if (result == 200) { msg.obj = 0; db.addServer(uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login required"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } new_repo.sendMessage(msg); } }); alrt.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); break; case REM_REPO: final Vector<String> rem_lst = new Vector<String>(); CharSequence[] b = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b[i] = server_lst.get(i).uri; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Chose repository to remove"); builder.setIcon(android.R.drawable.ic_menu_close_clear_cancel); builder.setMultiChoiceItems(b, null, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { if (isChecked) { rem_lst.addElement(server_lst.get(whichButton).uri); } else { rem_lst.removeElement(server_lst.get(whichButton).uri); } } }); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { db.removeServer(rem_lst); change = true; redraw(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); AlertDialog alert = builder.create(); alert.show(); break; case EDIT_REPO: CharSequence[] b2 = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b2[i] = server_lst.get(i).uri; } AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle("Chose repository to edit"); builder2.setIcon(android.R.drawable.ic_menu_edit); builder2.setSingleChoiceItems(b2, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updt_repo = server_lst.get(which).uri; } }); builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { editRepo(updt_repo); return; } }); builder2.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); alert2 = builder2.create(); alert2.show(); break; } return super.onMenuItemSelected(featureId, item); }
From source file:se.anyro.tagtider.TransferActivity.java
private AlertDialog createSmsDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.sms_dialog_title); if (mPhoneNumber == null) { builder.setMessage(R.string.sms_dialog_message); } else {//from www.ja va 2 s . co m builder.setMessage(String.format(getString(R.string.sms_dialog_message_free), mPhoneNumber)); } builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mPhoneNumber == null) { sendSms("0730121096", mTrain + " " + mStationId); } else { new StartSubscriptionTask().execute(mPhoneNumber, TYPE_SMS); } } }); builder.setNegativeButton("Avbryt", null); final AlertDialog smsDialog = builder.create(); return smsDialog; }
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android alert with given Strings * @param message The message the alert should display * @param title The title of the alert * @param buttonLabel The label of the button * @param callbackContext The callback context *//*from ww w. ja va2 s. c o m*/ public synchronized void list(final String title, final JSONArray data, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; final String[] options = new String[data.length()]; for (int i = 0; i < data.length(); i++) { try { options[i] = data.getString(i); } catch (JSONException e) { e.printStackTrace(); } } Runnable runnable = new Runnable() { public void run() { final JSONObject result = new JSONObject(); AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setTitle(title); dlg.setCancelable(false); dlg.setItems(options, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 1); result.put("selectedIndex", which); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); dlg.setNegativeButton("Cancel", new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 0); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); try { result.put("buttonIndex", 0); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.spydiko.rotationmanager.MainActivity.java
public void showPlayStoreDialog(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Add the buttons builder.setTitle("Spydiko"); builder.setMessage(R.string.landing_msg); builder.setIcon(R.drawable.icon);/*w w w . j a v a 2s . c o m*/ builder.setPositiveButton(R.string.playStore, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=pub:Spydiko")); startActivity(intent); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Set other dialog properties // Create the AlertDialog AlertDialog dialog = builder.create(); // AppSpecificOrientation.ALREADY_SHOWED = true; // AppSpecificOrientation.RETURN_FROM_ABOUT = false; dialog.show(); }