List of usage examples for android.app AlertDialog setMessage
public void setMessage(CharSequence message)
From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java
public boolean checkStackTrace() { FileInputStream traceIn = null; try {/*from w w w. j a v a2 s . co m*/ 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:com.jwork.dhammapada.MainActivity.java
private void showCrashDialog() { final CrashHandler handler = CrashHandler.getInstance(); final AlertDialog ad = new AlertDialog.Builder(this).create(); ad.setTitle("Error Report"); ad.setMessage("An error was detected. Reporting it will support faster bug fixing."); ad.setButton(AlertDialog.BUTTON_POSITIVE, "Report it", new DialogInterface.OnClickListener() { @Override//from w w w .ja va 2s . c o m public void onClick(DialogInterface dialog, int which) { handler.clearCrashFlag(); ad.dismiss(); MainActivity.this.finish(); handler.sendEmail(MainActivity.this); // MainActivity.this.startActivity(new Intent(MainActivity.this, MainActivity.class)); } }); ad.setButton(AlertDialog.BUTTON_NEGATIVE, "Not now", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.clearCrashFlag(); ad.dismiss(); MainActivity.this.finish(); MainActivity.this.startActivity(new Intent(MainActivity.this, MainActivity.class)); } }); ad.show(); }
From source file:com.repay.android.adddebt.AddDebtActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null && requestCode == 1) { try {//from ww w . java 2 s .c om Log.i(TAG, "Closing contact picker"); Uri contactUri = data.getData(); String[] cols = { ContactsContract.Contacts.DISPLAY_NAME }; Cursor cursor = getContentResolver().query(contactUri, cols, null, null, null); cursor.moveToFirst(); String result = cursor.getString(0).replaceAll("[-+.^:,']", ""); Friend pickerResult = new Friend(DatabaseHandler.generateRepayID(), contactUri, result, new BigDecimal("0")); mDB.addFriend(pickerResult); ((ChoosePersonFragment) mChoosePerson).dataSetChanged(); } catch (IndexOutOfBoundsException e) { Toast.makeText(this, "Problem in getting result from your contacts", Toast.LENGTH_SHORT).show(); } catch (SQLException e) { e.printStackTrace(); AlertDialog alert = new AlertDialog.Builder(this).create(); alert.setMessage("This person already exists in Repay"); alert.setTitle("Person Already Exists"); Log.i(TAG, "Person already exists within app database"); alert.show(); } } }
From source file:com.google.cast.samples.games.spellcast.MainActivity.java
/** * Shows an error dialog./*from w ww. j a va 2 s . c o m*/ * * @param errorMessage The message to show in the dialog. */ private void showErrorDialog(final String errorMessage) { if (!isDestroyed()) { runOnUiThread(new Runnable() { @Override public void run() { // Show a error dialog along with error messages. AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(getString(R.string.game_connection_error_message)); alertDialog.setMessage(errorMessage); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.game_dialog_ok_button_text), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); } }); } }
From source file:com.paranoid.lukemovement.halolauncher.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try {//from ww w. ja v a2s. com } catch (Exception e) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage( "This app will not work on your device because your rom does not support HALO\n\nPlease install a rom that does support this feature(e.g. 'Paranoid Android')"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); } SP = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:markson.visuals.sitapp.CCActivity.java
@SuppressWarnings("deprecation") public void download() { AlertDialog alertDialog = new AlertDialog.Builder(CCActivity.this).create(); alertDialog.setTitle(cclass);/*from w w w .ja v a 2s. com*/ alertDialog.setMessage("Class: " + num + "\n" + "Professor: " + instructor + "\n" + "Time: " + time + "\n" + "Date: " + date + "\n" + "CRN: " + crn + "\n"); alertDialog.setButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
From source file:com.metinkale.prayerapp.vakit.fragments.SortFragment.java
public void onItemDismiss(final int position) { final Times times = Times.getTimesAt(position); AlertDialog dialog = new AlertDialog.Builder(getActivity()).create(); dialog.setTitle(R.string.delete);// w w w. j av a2 s. co m dialog.setMessage(getString(R.string.delConfirm, times.getName())); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int buttonId) { times.delete(); mAdapter.notifyItemRemoved(position); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int buttonId) { dialog.cancel(); mAdapter.notifyDataSetChanged(); } }); dialog.show(); }
From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // exit the app case R.id.exit: Toast.makeText(this, "Closing...", Toast.LENGTH_SHORT).show(); //System.exit(0); this.finish(); break;/*from w w w . j a v a 2s . c o m*/ // show the FAQ case R.id.help: AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle("FAQ"); dialog.setMessage(Constants.FAQ); dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20); break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:org.odk.collect.android.activities.InstanceChooserList.java
private void createErrorDialog(String errorMsg, final boolean shouldExit) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_info); alertDialog.setMessage(errorMsg); DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() { @Override// www . j a v a2 s. c o m public void onClick(DialogInterface dialog, int i) { switch (i) { case DialogInterface.BUTTON_POSITIVE: if (shouldExit) { finish(); } break; } } }; alertDialog.setCancelable(false); alertDialog.setButton(getString(R.string.ok), errorListener); alertDialog.show(); }
From source file:com.swissbit.homeautomation.asyncTask.AuthenticationAsync.java
/** *Show the dialog message after the RaspberryPi authentication *///from w ww . j av a 2s.co m 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(); }