List of usage examples for android.app AlertDialog setMessage
public void setMessage(CharSequence message)
From source file:org.openremote.android.console.AppSettingsActivity.java
@Override public void urlConnectionDidReceiveResponse(HttpResponse httpResponse) { int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != Constants.HTTP_SUCCESS) { loadingPanelProgress.dismiss();/*from ww w . j ava2 s . c o m*/ if (statusCode == ControllerException.UNAUTHORIZED) { LoginDialog loginDialog = new LoginDialog(this); loginDialog.setOnClickListener(loginDialog.new OnloginClickListener() { @Override public void onClick(View v) { super.onClick(v); requestPanelList(); checkAuthentication(); requestAccess(); } }); } else { // The following code customizes the dialog, because the finish method should do after dialog show and click ok. AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Panel List Not Found"); alertDialog.setMessage(ControllerException.exceptionMessageOfCode(statusCode)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); } } }
From source file:org.odk.collect.android.activities.GoogleDriveActivity.java
private void createAlertDialog(String message) { Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "show"); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.download_forms_result)); alertDialog.setMessage(message); DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() { @Override//from w w w. j av a 2 s.com public void onClick(DialogInterface dialog, int i) { switch (i) { case DialogInterface.BUTTON1: // ok Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "OK"); alertShowing = false; finish(); break; } } }; alertDialog.setCancelable(false); alertDialog.setButton(getString(R.string.ok), quitListener); alertDialog.setIcon(android.R.drawable.ic_dialog_info); alertShowing = true; alertMsg = message; alertDialog.show(); }
From source file:info.corne.performancetool.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem menu) { switch (menu.getItemId()) { case R.id.menu_refresh: getHardwareInfo();/*w w w .j av a 2 s . c o m*/ return true; case R.id.menu_about: // Show the about dialog. AlertDialog aboutDialog = new AlertDialog.Builder(this).create(); aboutDialog.setTitle("About"); aboutDialog.setMessage(getResources().getString(R.string.about_info)); aboutDialog.setIcon(R.drawable.ic_launcher); aboutDialog.show(); return true; case R.id.menu_onboot: applySetOnBoot(menu); return true; case R.id.menu_apply: switch (currentTab) { case 1: applyCpuSettings(null); break; case 2: applyAdvancedSettings(null); break; case 3: applyGpuSettings(null); break; } ; return true; } return super.onOptionsItemSelected(menu); }
From source file:fm.smart.r1.activity.ItemActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); // this should be called once image has been chosen by user // using requestCode to pass item id - haven't worked out any other way // to do it/*www.j a va 2 s . c o m*/ // if (requestCode == SELECT_IMAGE) if (resultCode == Activity.RESULT_OK) { // TODO check if user is logged in if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid navigation back to this? LoginActivity.return_to = ItemActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("item_id", (String) item.item_node.atts.get("id")); startActivity(intent); // TODO in this case forcing the user to rechoose the image // seems a little // rude - should probably auto-submit here ... } else { // Bundle extras = data.getExtras(); // String sentence_id = (String) extras.get("sentence_id"); final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Uploading image ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add_image = new Thread() { public void run() { // TODO needs to check for interruptibility String sentence_id = Integer.toString(requestCode); Uri selectedImage = data.getData(); // Bitmap bitmap = Media.getBitmap(getContentResolver(), // selectedImage); // ByteArrayOutputStream bytes = new // ByteArrayOutputStream(); // bitmap.compress(Bitmap.CompressFormat.JPEG, 40, // bytes); // ByteArrayInputStream fileInputStream = new // ByteArrayInputStream( // bytes.toByteArray()); // TODO Might have to save to file system first to get // this // to work, // argh! // could think of it as saving to cache ... // add image to sentence FileInputStream is = null; FileOutputStream os = null; File file = null; ContentResolver resolver = getContentResolver(); try { Bitmap bitmap = Media.getBitmap(getContentResolver(), selectedImage); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes); // ByteArrayInputStream bais = new // ByteArrayInputStream(bytes.toByteArray()); // FileDescriptor fd = // resolver.openFileDescriptor(selectedImage, // "r").getFileDescriptor(); // is = new FileInputStream(fd); String filename = "test.jpg"; File dir = ItemActivity.this.getDir("images", MODE_WORLD_READABLE); file = new File(dir, filename); os = new FileOutputStream(file); // while (bais.available() > 0) { // / os.write(bais.read()); // } os.write(bytes.toByteArray()); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } if (is != null) { try { is.close(); } catch (IOException e) { } } } // File file = new // File(Uri.decode(selectedImage.toString())); // ensure item is in users default list ItemActivity.add_item_result = addItemToList(Main.default_study_list_id, (String) item.item_node.atts.get("id"), ItemActivity.this); Result result = ItemActivity.add_item_result; if (ItemActivity.add_item_result.success() || ItemActivity.add_item_result.alreadyInList()) { // ensure sentence is in users default list ItemActivity.add_sentence_list_result = addSentenceToList(sentence_id, (String) item.item_node.atts.get("id"), Main.default_study_list_id, ItemActivity.this); result = ItemActivity.add_sentence_list_result; if (ItemActivity.add_sentence_list_result.success()) { String media_entity = "http://test.com/test.jpg"; String author = "tansaku"; String author_url = "http://smart.fm/users/tansaku"; Log.d("DEBUG-IMAGE-URI", selectedImage.toString()); ItemActivity.add_image_result = addImage(file, media_entity, author, author_url, "1", sentence_id, (String) item.item_node.atts.get("id"), Main.default_study_list_id); result = ItemActivity.add_image_result; } } final Result display = result; myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(display.getTitle()); dialog.setMessage(display.getMessage()); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (ItemActivity.add_image_result != null && ItemActivity.add_image_result.success()) { ItemListActivity.loadItem(ItemActivity.this, item.item_node.atts.get("id").toString()); } } }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add_image.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add_image.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add_image.start(); } } }
From source file:com.android.quake.llvm.DownloaderActivity.java
private void onDownloadFailed(String reason) { Log.e(LOG_TAG, "Download stopped: " + reason); String shortReason;//from w w w .j a v a 2 s . c om int index = reason.indexOf('\n'); if (index >= 0) { shortReason = reason.substring(0, index); } else { shortReason = reason; } AlertDialog alert = new Builder(this).create(); alert.setTitle(R.string.download_activity_download_stopped); if (!mSuppressErrorMessages) { alert.setMessage(shortReason); } alert.setButton(getString(R.string.download_activity_retry), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startDownloadThread(); } }); alert.setButton2(getString(R.string.download_activity_quit), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); try { alert.show(); } catch (WindowManager.BadTokenException e) { // Happens when the Back button is used to exit the activity. // ignore. } }
From source file:net.homelinux.penecoptero.android.citybikes.app.MainActivity.java
private void showAutoNetworkDialog(int method) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_map); final int mth = method; try {/*from w w w . ja v a2s. c o m*/ mNDBAdapter.update(); final JSONObject network = mNDBAdapter.getAutomaticNetwork(hOverlay.getPoint(), method); alertDialog.setTitle(R.string.bike_network_alert_success_title); alertDialog.setMessage(getString(R.string.bike_network_alert_success_text0) + ":\n- (" + network.getString("city") + ") " + network.getString("name") + "\n" + getString(R.string.bike_network_alert_success_text1)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.sure), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { mNDBAdapter.setManualNetwork(network.getInt("id")); fillData(view_all); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.try_again), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); alertDialog.setTitle(R.string.bike_network_alert_error_title); alertDialog.setMessage(getString(R.string.bike_network_alert_error_text)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.try_again), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mth == 0) showAutoNetworkDialog(1); else showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); } alertDialog.show(); }
From source file:com.data.pack.ViewVideo.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.videoplay);/* w ww. ja va 2s . c o m*/ Intent i = getIntent(); Bundle extras = i.getExtras(); filename = extras.getString("workoutname"); workoutID = extras.getString("workoutID"); UserName = extras.getString("UserName"); userID = extras.getString("userID"); // l= (View)findViewById(R.id.btnnavigation); btnQuit = (Button) findViewById(R.id.headeQuitricon); // btnplay =(Button)findViewById(R.id.btnplay); placeData = new PlaceDataSQL(this); GlobalData.appcount++; if (arrVoVideoName == null) arrVoVideoName = new ArrayList<VOWorkoutVideos>(); GlobalData.viewvideochange = 0; if (videoPathes == null) videoPathes = new ArrayList<Object>(); WindowManager.LayoutParams params = getWindow().getAttributes(); params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; // params.screenBrightness = 10; getWindow().setAttributes(params); if (obUser.getSelectedLanguage().equals("1")) { YesString = "Yes"; strLeaveVideo = "You are about to exit the Video. Are you sure ?"; NoString = "No"; } else { YesString = "Ja"; QuitString = "verlassen"; strLeaveVideo = "Du bist dabei das Video zu beenden, bist Du sicher ?"; NoString = "Nein"; } count = 1; // Toast.makeText(getBaseContext(), "countcountcountcount" // +count,Toast.LENGTH_LONG).show(); // btnQuit =(Button) findViewById(R.id.headeQuitricon); btnQuit.setText(QuitString); btnQuit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // Intent intent = new Intent(sharescreen.this, // HomeScreen.class); // // intent.putExtra("userID", userID); // startActivity(intent); AlertDialog alertDialog = new AlertDialog.Builder(ViewVideo.this).create(); if (mVideoView.isPlaying()) { mVideoView.pause(); } alertDialog.setTitle("fitness4.me"); alertDialog.setMessage(strLeaveVideo); alertDialog.setButton(-1, YesString, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { try { GlobalData.viewvideochange = 1; Intent intent = new Intent(ViewVideo.this, FitnessforMeActivity.class); startActivity(intent); if (mVideoView != null) mVideoView.stopPlayback(); } catch (Exception e) { // TODO: handle exception } } }); alertDialog.setButton(-2, NoString, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { GlobalData.viewvideochange = 0; mVideoView.start(); dialog.cancel(); } }); try { alertDialog.show(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mycontroller = new MediaController(this); mVideoView = (VideoView) findViewById(R.id.surface_view); mVideoView.setMediaController(null); AdView adView = (AdView) this.findViewById(R.id.adView); if (GlobalData.allPurchased == true) { adView.setVisibility(View.GONE); } else { adView.setVisibility(View.VISIBLE); adView.loadAd(new AdRequest()); } try { myTimer = new Timer(); myTimer.schedule(new TimerTask() { @Override public void run() { TimerMethod(); } }, 1, 1000); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } mVideoView.setOnCompletionListener(myVideoViewCompletionListener); getDataAndPopulate(); }
From source file:de.tum.frm2.nicos_android.gui.MainActivity.java
@Override public void handleSignal(String signal, Object data, Object args) { switch (signal) { case "broken": final String error = (String) data; // Connection is broken. Try to disconnect what's left and go back to login screen. NicosClient.getClient().unregisterCallbackHandler(this); NicosClient.getClient().disconnect(); if (!_visible) return; // Activity is still visible, user probably didn't intend to shut down connection. // We display an error. runOnUiThread(new Runnable() { @Override/* w ww . j ava 2s .c o m*/ public void run() { AlertDialog alertDialog; try { alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle("Disconnected"); alertDialog.setMessage(error); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } catch (Exception e) { try { finish(); } catch (Exception e2) { // User probably quit the application. } // Activity isn't running anymore // (user probably put application in background). } } }); break; case "cache": on_client_cache((Object[]) data); break; case "status": // data = tuple of (status, linenumber) _current_status = (int) ((Object[]) data)[0]; break; case "message": final ArrayList msgList = (ArrayList) data; if ((int) msgList.get(2) == NicosMessageLevel.ERROR) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), NicosMessageLevel.level2name(NicosMessageLevel.ERROR) + ": " + msgList.get(3), Toast.LENGTH_SHORT).show(); } }); } break; case "error": final String msg = (String) data; runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); } }); break; } }
From source file:net.cloudpath.xpressconnect.screens.ScreenBase.java
protected void alertThenDie(int paramInt1, String paramString, int paramInt2) { AlertDialog localAlertDialog = new AlertDialog.Builder(this).create(); if (localAlertDialog == null) { done(0);/*ww w . j a va2 s . co m*/ return; } String str1 = getString(paramInt1); if (str1 == null) str1 = new String("Alert!"); localAlertDialog.setTitle(str1); localAlertDialog.setMessage(paramString); String str2 = getString(paramInt2); if (str2 == null) str2 = new String("Okay"); localAlertDialog.setButton(-2, str2, new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { ScreenBase.this.quit(); } }); localAlertDialog.show(); }
From source file:cm.aptoide.pt.ScheduledDownloads.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Builder dialogBuilder = new AlertDialog.Builder(this); final AlertDialog scheduleDialog = dialogBuilder.create(); // AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); switch (item.getItemId()) { case 0://from w ww. jav a 2 s . c o m for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { scheduledDownloadsHashMap.get(scheduledDownload).toggleChecked(); } adapter.notifyDataSetInvalidated(); break; case 1: if (isAllChecked()) { scheduleDialog.setTitle(getText(R.string.schDwnBtn)); scheduleDialog.setIcon(android.R.drawable.ic_menu_close_clear_cancel); scheduleDialog.setCancelable(false); scheduleDialog.setMessage(getText(R.string.schDown_sureremove)); scheduleDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { if (scheduledDownloadsHashMap.get(scheduledDownload).checked) { db.deleteScheduledDownload(scheduledDownload); } } getSupportLoaderManager().restartLoader(0, null, ScheduledDownloads.this); return; } }); scheduleDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.cancel(); } }); scheduleDialog.show(); } else { Toast toast = Toast.makeText(this, getString(R.string.schDown_nodownloadselect), Toast.LENGTH_SHORT); toast.show(); } break; default: break; } return true; }