Example usage for android.app AlertDialog.Builder setMessage

List of usage examples for android.app AlertDialog.Builder setMessage

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setMessage.

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:com.example.run_tracker.RunFragment.java

private void show_confirm() {
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override//from  w ww . j a v  a  2  s. co  m
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:

                save_track();
                // Yes button clicked save and clear
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                // No button clicked do nothing
                break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
            .setNegativeButton("No", dialogClickListener).show();
}

From source file:com.phonegap.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 callbackId   The callback id//from  ww  w.j  a  v a  2  s . c  om
 */
public synchronized void alert(final String message, final String title, final String buttonLabel,
        final String callbackId) {

    final PhonegapActivity ctx = this.ctx;
    final Notification notification = this;

    Runnable runnable = new Runnable() {
        public void run() {

            AlertDialog.Builder dlg = new AlertDialog.Builder(ctx);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);
            dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    notification.success(new PluginResult(PluginResult.Status.OK, 0), callbackId);
                }
            });
            dlg.create();
            dlg.show();
        };
    };
    this.ctx.runOnUiThread(runnable);
}

From source file:truesculpt.ui.panels.WebFilePanel.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getManagers().getUtilsManager().updateFullscreenWindowStatus(getWindow());

    setContentView(R.layout.webfile);/*from w w w  .j av a2 s .  c  o  m*/

    getManagers().getUsageStatisticsManager().TrackEvent("OpenFromWeb", "", 1);

    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.setWebViewClient(new MyWebViewClient());
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(new JavaScriptInterface(this, getManagers()), "Android");

    int nVersionCode = getManagers().getUpdateManager().getCurrentVersionCode();
    mWebView.loadUrl(mStrBaseWebSite + "?version=" + nVersionCode);

    mPublishToWebBtn = (Button) findViewById(R.id.publish_to_web);
    mPublishToWebBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String name = getManagers().getMeshManager().getName();
            final File imagefile = new File(getManagers().getFileManager().GetImageFileName());
            final File objectfile = new File(getManagers().getFileManager().GetObjectFileName());

            getManagers().getUsageStatisticsManager().TrackEvent("PublishToWeb", name, 1);

            if (imagefile.exists() && objectfile.exists()) {
                try {
                    final File zippedObject = File.createTempFile("object", "zip");
                    zippedObject.deleteOnExit();

                    BufferedReader in = new BufferedReader(new FileReader(objectfile));
                    BufferedOutputStream out = new BufferedOutputStream(
                            new GZIPOutputStream(new FileOutputStream(zippedObject)));
                    System.out.println("Compressing file");
                    int c;
                    while ((c = in.read()) != -1) {
                        out.write(c);
                    }
                    in.close();
                    out.close();

                    long size = 0;

                    size = new FileInputStream(imagefile).getChannel().size();
                    size += new FileInputStream(zippedObject).getChannel().size();
                    size /= 1000;

                    final SpannableString msg = new SpannableString(
                            "You will upload your latest saved version of this scupture representing " + size
                                    + " ko of data\n\n"
                                    + "When clicking the yes button you accept to publish your sculpture under the terms of the creative commons share alike, non commercial license\n"
                                    + "http://creativecommons.org/licenses/by-nc-sa/3.0"
                                    + "\n\nDo you want to proceed ?");
                    Linkify.addLinks(msg, Linkify.ALL);

                    AlertDialog.Builder builder = new AlertDialog.Builder(WebFilePanel.this);
                    builder.setMessage(msg).setCancelable(false)
                            .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int id) {
                                    PublishPicture(imagefile, zippedObject, name);
                                }
                            }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int id) {

                                }
                            });
                    AlertDialog dlg = builder.create();
                    dlg.show();

                    // Make the textview clickable. Must be called after
                    // show()
                    ((TextView) dlg.findViewById(android.R.id.message))
                            .setMovementMethod(LinkMovementMethod.getInstance());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(WebFilePanel.this);
                builder.setMessage(
                        "File has not been saved, you need to save it before publishing\nDo you want to proceed to save window ?")
                        .setCancelable(false)
                        .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {
                                ((FileSelectorPanel) getParent()).getTabHost().setCurrentTab(2);
                            }
                        }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {
                            }
                        });
                builder.show();
            }
        }
    });
}

From source file:ar.uba.fi.mileem.SimpleFormActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_legalnotices:
        String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(SimpleFormActivity.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();//w  ww .j av  a 2s .c o m
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.spoiledmilk.ibikecph.IssuesActivity.java

public void onButtonSendClick(View v) {
    if (currentOption != null) {
        new Thread(new Runnable() {
            @Override/*from  w  w  w  . j av a2 s .  co m*/
            public void run() {
                JsonNode response = null;
                JSONObject jsonPost = new JSONObject();
                String auth_token = IbikeApplication.getAuthToken();
                try {
                    jsonPost.put("auth_token", auth_token);
                    JSONObject jsonIssue = new JSONObject();
                    jsonIssue.put("route_segment", spinner.getSelectedItem().toString());
                    jsonIssue.put("error_type", currentOption.getText().toString());
                    String comment = "";
                    comment += IbikeApplication.getString("report_from") + "\n";
                    comment += startName + "\n" + startLoc + "\n\n";
                    comment += IbikeApplication.getString("report_to") + "\n";
                    comment += endName + "\n" + endLoc + "\n\n";
                    comment += IbikeApplication.getString("report_reason") + "\n";
                    comment += currentOption.getText().toString() + "\n\n";
                    comment += (currentComment == null ? "" : currentComment.getText().toString()) + "\n\n";
                    comment += spinner.getSelectedItem().toString() + "\n\n";
                    comment += IbikeApplication.getString("report_tbt_instructions") + "\n";
                    for (String turn : turns) {
                        comment += turn + "\n";
                    }
                    jsonIssue.put("comment", comment);
                    jsonPost.put("issue", jsonIssue);
                    response = HttpUtils.postToServer(Config.serverUrl + "/issues", jsonPost);
                    IbikeApplication.getTracker().sendEvent("Report", "Completed", "", (long) 0);
                } catch (JSONException e) {
                    LOG.e(e.getLocalizedMessage());
                } finally {
                    final JsonNode responseTemp = response;
                    IssuesActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            String message = IbikeApplication.getString("Error");
                            if (responseTemp != null && responseTemp.has("info")) {
                                message = responseTemp.get("info").asText();
                                LOG.d("issues response message = " + message);
                            }
                            AlertDialog.Builder builder = new AlertDialog.Builder(IssuesActivity.this);
                            builder.setMessage(message);
                            builder.setPositiveButton("OK", new OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    finish();
                                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                                }
                            });
                            builder.show();
                        }
                    });

                }
            }
        }).start();

    }
}

From source file:com.cloudtask1.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *///w w  w. j a  va2  s.  co m
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Set "connecting" status
                SharedPreferences prefs = Util.getSharedPreferences(mContext);
                prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit();
                // Get account name
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                // Register
                register((String) account.getText());
                finish();
            }
        });
    }
}

From source file:nz.ac.wintec.soit.af5.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *///from  w  w  w. java 2 s . c  om
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //  startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Set "connecting" status
                SharedPreferences prefs = Util.getSharedPreferences(mContext);
                prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit();
                // Get account name
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                // Register
                register((String) account.getText());
                finish();
            }
        });
    }
}

From source file:com.restswitch.controlpanel.MainActivity.java

private void alertError(String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Error");
    builder.setMessage(msg);
    builder.setNeutralButton("OK", null);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.show();//from  w w  w . j av  a  2s. c o m
}

From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

private void handleExtra(Intent intent) {
    Bundle extras = intent.getExtras();//from w w  w . ja  v a  2  s  .  c o m
    if (extras != null && extras.size() > 0) {
        for (String k : extras.keySet()) {
            Log.i(TAG, "k = " + k + " : " + extras.getString(k));
        }
    }
    if (extras != null && "dialog".equals(extras.get("_extra1"))) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setTitle("" + extras.get("_extra2"));
        alertDialogBuilder.setMessage("" + extras.get("_extra3")).setCancelable(false).setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        alertDialogBuilder.create().show();
    }
}

From source file:com.javierc.albuquerquenow.TransitMap.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    if (item.getItemId() == R.id.offline_routes) {

        if (item.isChecked()) {
            item.setChecked(false);/*from   w  ww  .  j av a 2  s .c o  m*/
            useOfflineRoutes = false;
        } else {
            item.setChecked(true);
            useOfflineRoutes = true;
        }

    } else if (item.getItemId() == R.id.action_legalnotices) {
        String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(TransitMap.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();

    } else if (item.getItemId() == R.id.bus_refresh) {
        //first delete all the current markers
        refreshMarkers();
        //plot new markers
        plotBus(actionBar.getSelectedNavigationIndex());

    } else if (item.getItemId() == R.id.bus_stops) {
        new PlotStopsTask(this).execute();
    }
    return super.onOptionsItemSelected(item);
}