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.kii.world.MainActivity.java

public void onListItemClick(ListView l, View v, final int position, long id) {

    // build the alert
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Would you like to remove this item?").setCancelable(true)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {

                // if the user chooses 'yes',
                public void onClick(DialogInterface dialog, int id) {

                    // perform the delete action on the tapped
                    // object
                    MainActivity.this.performDelete(position);
                }//from   w  w  w  .ja va 2s .  c o  m
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {

                // if the user chooses 'no'
                public void onClick(DialogInterface dialog, int id) {

                    // simply dismiss the dialog
                    dialog.cancel();
                }
            });

    // show the dialog
    builder.create().show();

}

From source file:com.locution.hereyak.LoginActivity.java

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

From source file:falcofinder.android.fuehrerschein.chat.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *//*w ww.j a v  a2  s .c  o  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);

        /* 
         * rimuovo aggiunta account perche' disponible da versione 2.2
         * ma voglio compatibilita' con 2.1
        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.emobc.android.activities.generators.FormActivityGenerator.java

/**
 * Check the contents of a web address to add new data to existing 
 * app.xml file. Then, it goes to the next level.
 * @param activity//from  w  w  w  .  j a  v a2 s .  c  o m
 */
protected void processSubmit(Activity activity) {
    try {
        List<NameValuePair> parameters = createParameters();
        try {
            URL url = new URL(item.getActionUrl());

            RetreiveFileContentTask task = new RetreiveFileContentTask(parameters, true);
            task.execute(url);
            try {
                String text = task.get();

                ApplicationData.mergeAppDataFromString(activity, text);

                showNextLevel(activity, item.getNextLevel());
            } catch (InterruptedException e) {
                Log.e("FormActivityGenerator: InterruptedException: ", e.getMessage());
            } catch (ExecutionException e) {
                Log.e("FormActivityGenerator: ExecutionException: ", e.getMessage());
            }
        } catch (MalformedURLException e1) {
        }
    } catch (final RequiredFieldException e) {
        final AlertDialog.Builder dlg = new AlertDialog.Builder(activity);
        dlg.setTitle(R.string.form_level_title);
        dlg.setMessage(R.string.form_level_alert_required_fields);
        dlg.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                View view = controlsMap.get(e.getDataItem().getFieldName());
                view.requestFocus();
            }
        });
        dlg.show();
    }
}

From source file:edu.cwru.apo.Home.java

public void onRestRequestComplete(Methods method, JSONObject result) {
    if (method == Methods.phone) {
        if (result != null) {
            try {
                String requestStatus = result.getString("requestStatus");
                if (requestStatus.compareTo("success") == 0) {
                    SharedPreferences.Editor editor = getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE)
                            .edit();/*from w  ww. j a v  a  2s. c o  m*/
                    editor.putLong("updateTime", result.getLong("updateTime"));
                    editor.commit();
                    int numbros = result.getInt("numBros");
                    JSONArray caseID = result.getJSONArray("caseID");
                    JSONArray first = result.getJSONArray("first");
                    JSONArray last = result.getJSONArray("last");
                    JSONArray phone = result.getJSONArray("phone");
                    JSONArray family = result.getJSONArray("family");
                    ContentValues values;
                    for (int i = 0; i < numbros; i++) {
                        values = new ContentValues();
                        values.put("_id", caseID.getString(i));
                        values.put("first", first.getString(i));
                        values.put("last", last.getString(i));
                        values.put("phone", phone.getString(i));
                        values.put("family", family.getString(i));
                        database.replace("phoneDB", null, values);
                    }
                } else if (requestStatus.compareTo("timestamp invalid") == 0) {
                    Toast msg = Toast.makeText(this, "Invalid timestamp.  Please try again.",
                            Toast.LENGTH_LONG);
                    msg.show();
                } else if (requestStatus.compareTo("HMAC invalid") == 0) {
                    Auth.loggedIn = false;
                    Toast msg = Toast.makeText(this,
                            "You have been logged out by the server.  Please log in again.", Toast.LENGTH_LONG);
                    msg.show();
                    finish();
                } else {
                    Toast msg = Toast.makeText(this, "Invalid requestStatus", Toast.LENGTH_LONG);
                    msg.show();
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } else if (method == Methods.checkAppVersion) {
        if (result != null) {
            try {
                String requestStatus = result.getString("requestStatus");
                if (requestStatus.compareTo("success") == 0) {
                    String appVersion = result.getString("version");
                    String appDate = result.getString("date");
                    final String appUrl = result.getString("url");
                    PackageInfo pinfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
                    ;
                    if (appVersion.compareTo(pinfo.versionName) != 0) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        builder.setTitle("Upgrade");
                        builder.setMessage("Update available, ready to upgrade?");
                        builder.setIcon(R.drawable.icon);
                        builder.setCancelable(false);
                        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                Intent promptInstall = new Intent("android.intent.action.VIEW",
                                        Uri.parse("https://apo.case.edu:8090/app/" + appUrl));
                                startActivity(promptInstall);
                            }
                        });
                        builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        });
                        AlertDialog alert = builder.create();
                        alert.show();
                    } else {
                        Toast msg = Toast.makeText(this, "No updates found", Toast.LENGTH_LONG);
                        msg.show();
                    }
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (NameNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}

From source file:com.kircherelectronics.fusedgyroscopeexplorer.sensor.GyroscopeSensor.java

private void showGyroscopeNotAvailableAlert() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    // set title//from   ww  w .  j  a  v a2 s  .c o  m
    alertDialogBuilder.setTitle("Gyroscope Not Available");

    // set dialog message
    alertDialogBuilder.setMessage("Your device is not equipped with a gyroscope or it is not responding...")
            .setCancelable(false)
            .setNegativeButton("I'll look around...", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked, just close
                    // the dialog box and do nothing
                    dialog.cancel();
                }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();
}

From source file:com.example.maproot.MainActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_A:/*from w  w  w .j a v  a 2s  . c  o m*/
        //show_mapInfo();
        return true;

    case MENU_B:
        //Legal Notices(?)

        String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(MainActivity.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();

        return true;

    case MENU_c:
        //show_settings();
        return true;

    }
    return false;
}

From source file:com.yairkukielka.feedhungry.EntryListFragment.java

private void showErrorDialog(String error) {
    AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
    b.setMessage(getResources().getString(R.string.generic_exception));
    b.show();//  ww  w.  j ava  2 s .  co  m
}

From source file:se.anyro.nfc_reader.TagViewer.java

private void showWirelessSettingsDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.nfc_disabled);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {
            Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
            startActivity(intent);/* ww  w .j av a 2s .  c  om*/
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {
            finish();
        }
    });
    builder.create().show();
    return;
}

From source file:de.teunito.android.cyclelife.RennradNewsShare.java

/** Called when the activity is first created. */
@Override//from  w  ww  .jav  a 2  s. c om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.share_rennradnews);

    Bundle data = new Bundle();
    data = getIntent().getExtras();
    trackId = data.getLong("trackId");

    mTrackDb = TrackDb.getInstance(getApplicationContext());

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    APIKey = prefs.getString(Preferences.RENNRADNEWS_API_KEY, "");
    bikeId = prefs.getString(Preferences.RENNRADNEWS_BIKE_ID, "");
    weight = prefs.getString(Preferences.WEIGHT, "");

    tv = (TextView) findViewById(R.id.rnsShareTitle);
    tv.setText("Share your track " + trackId + " to rennrad-news.de community!");
    bt = (Button) findViewById(R.id.rnsShareBtn);
    etTemp = (EditText) findViewById(R.id.rnsShareTemp);
    spSports = (Spinner) findViewById(R.id.rnsShareSports);
    spZone = (Spinner) findViewById(R.id.rnsShareZone);
    spWeather = (Spinner) findViewById(R.id.rnsShareWeather);
    spMood = (Spinner) findViewById(R.id.rnsShareMood);

    sportsAdapter = ArrayAdapter.createFromResource(this, R.array.sports, android.R.layout.simple_spinner_item);
    zoneAdapter = ArrayAdapter.createFromResource(this, R.array.zone, android.R.layout.simple_spinner_item);
    weatherAdapter = ArrayAdapter.createFromResource(this, R.array.weather,
            android.R.layout.simple_spinner_item);
    moodAdapter = ArrayAdapter.createFromResource(this, R.array.mood, android.R.layout.simple_spinner_item);

    sportsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    zoneAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    weatherAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    moodAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spSports.setAdapter(sportsAdapter);
    spZone.setAdapter(zoneAdapter);
    spWeather.setAdapter(weatherAdapter);
    spMood.setAdapter(moodAdapter);

    bt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog = ProgressDialog.show(RennradNewsShare.this, "", "Uploading. Please wait...", true);

            sportsID = String.valueOf(spSports.getSelectedItemPosition() + 1);
            zoneId = String.valueOf(spZone.getSelectedItemPosition() + 1);
            weatherId = String.valueOf(spWeather.getSelectedItemPosition() + 1);
            moodId = String.valueOf(spMood.getSelectedItemPosition() + 1);
            temperature = etTemp.getText().toString();

            // execute is a blocking call, it's best to call this code in a thread separate from the ui's
            uploadThread.start();
        }
    });

    handler = new Handler() {
        public void handleMessage(Message msg) {
            String result = msg.getData().getString("result");
            if (result.contains("success")) {
                Toast.makeText(getApplicationContext(), "Uploaded: " + result, Toast.LENGTH_LONG).show();
                finish();
            } else
                Toast.makeText(getApplicationContext(), "Error: " + result, Toast.LENGTH_LONG).show();
        }
    };

    if (APIKey.length() < 20) {
        AlertDialog.Builder builder = new AlertDialog.Builder(RennradNewsShare.this);
        builder.setMessage("Please enter first the rennrad-news.de API-key in the Settings!")
                .setCancelable(false).setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        RennradNewsShare.this.finish();
                        startActivity(new Intent(RennradNewsShare.this, Preferences.class));
                    }
                });
        builder.create().show();
    }
}