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.nokia.example.capturetheflag.Controller.java

private void showEnableGPSDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage(getResources().getText(R.string.gps_not_enabled));

    builder.setPositiveButton(getResources().getText(R.string.action_settings), new OnClickListener() {
        @Override//from  ww  w  .j a v a  2s . co  m
        public void onClick(DialogInterface dialog, int which) {
            Intent i = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            getActivity().startActivity(i);
        }
    });

    builder.setNegativeButton(getResources().getText(R.string.cancel), new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.create().show();
}

From source file:org.dvbviewer.controller.ui.fragments.StreamConfig.java

@Override
public void onClick(View v) {
    Intent videoIntent = null;//w  w w  .  j  a v  a2 s. c  om
    switch (v.getId()) {
    case R.id.startTranscodedButton:
        mStreamType = STREAM_TYPE_TRANSCODE;
        videoIntent = getVideoIntent();
        try {
            startActivity(videoIntent);
            if (UIUtils.isTablet(getActivity())) {
                getDialog().dismiss();
            } else {
                getActivity().finish();
            }
        } catch (ActivityNotFoundException e) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage(getResources().getString(R.string.noFlashPlayerFound))
                    .setPositiveButton(getResources().getString(R.string.yes), this)
                    .setNegativeButton(getResources().getString(R.string.no), this).show();

            e.printStackTrace();
        }
        break;
    case R.id.startDirectButton:
        mStreamType = STREAM_TYPE_DIRECT;
        videoIntent = getVideoIntent();
        try {
            startActivity(videoIntent);
            if (UIUtils.isTablet(getActivity())) {
                getDialog().dismiss();
            } else {
                getActivity().finish();
            }
        } catch (ActivityNotFoundException e) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage(getResources().getString(R.string.noFlashPlayerFound))
                    .setPositiveButton(getResources().getString(R.string.yes), this)
                    .setNegativeButton(getResources().getString(R.string.no), this).show();

            e.printStackTrace();
        }
        break;

    default:
        break;
    }
}

From source file:com.dattasmoon.pebble.plugin.ConvertPreference.java

@Override
protected void onBindDialogView(View view) {
    Button btnAdd = (Button) view.findViewById(R.id.btnAdd);
    etFrom = (EditText) view.findViewById(R.id.etFrom);
    etTo = (EditText) view.findViewById(R.id.etTo);
    lvConvert = (ListView) view.findViewById(R.id.lvConvert);
    lvConvert.setEmptyView(view.findViewById(android.R.id.empty));
    lvConvert.setAdapter(arrayAdapter);/*ww  w  .  j  a  va2s.c om*/
    lvConvert.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
            AdapterView.AdapterContextMenuInfo contextInfo = (AdapterView.AdapterContextMenuInfo) menuInfo;
            int position = contextInfo.position;
            long id = contextInfo.id;
            // the child view who's info we're viewing (should be equal to v)
            View v = contextInfo.targetView;
            AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());

            final int arrayPosition = (Integer) v.getTag();
            final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString();
            builder.setMessage(
                    getContext().getResources().getString(R.string.confirm_delete) + " '" + text + "' ?")
                    .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            JSONArray temp = new JSONArray();
                            for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) {
                                if (i == arrayPosition) {
                                    continue;
                                }
                                try {
                                    temp.put(arrayAdapter.getJSONArray().getJSONObject(i));
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                            }
                            arrayAdapter.setJSONArray(temp);

                            arrayAdapter.notifyDataSetChanged();
                        }
                    }).setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // User cancelled the dialog
                        }
                    });
            builder.create().show();
        }
    });

    btnAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            JSONObject item = new JSONObject();
            try {
                item.put("from", etFrom.getText().toString());
                item.put("to", etTo.getText().toString());
                arrayAdapter.getJSONArray().put(item);
                etFrom.setText("");
                etTo.setText("");
                arrayAdapter.notifyDataSetChanged();
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    });
    super.onBindDialogView(view);
}

From source file:de.evilbrain.sendtosftp.Main.java

public String serverListGetActive() {

    // Get selected Radio Button
    int selectedId = serverList.getCheckedRadioButtonId();

    // Get text from radio-button
    RadioButton actualradioButton = (RadioButton) findViewById(selectedId);
    if (actualradioButton == null) {
        AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
        dlgAlert.setTitle("Select an Server");
        dlgAlert.setMessage("Please select an server from the list");
        dlgAlert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

            }//from w w  w .j ava2 s.  c o  m
        });
        dlgAlert.setCancelable(true);
        dlgAlert.create().show();

        return null;
    }

    return actualradioButton.getText().toString();
}

From source file:com.google.zxing.client.android.history.HistoryActivity.java

public void limpaHistorico() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this, 3);
    builder.setMessage(R.string.msg_sure);
    builder.setCancelable(true);//from  w w w .  java 2  s  .c  om
    builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i2) {
            historyManager.clearHistory();
            dialog.dismiss();
            finish();
        }
    });
    builder.setNegativeButton(R.string.button_cancel, null);
    builder.show();
}

From source file:com.example.android.rowanparkingpass.Activities.CreateVehicleActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent myIntent;//ww  w .  j a  v  a  2 s  . c o m
    switch (item.getItemId()) {
    // action with ID action_delete was selected
    case R.id.action_delete:
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(CreateVehicleActivity.this);
        alertDialog.setTitle("Delete Driver?");
        alertDialog.setMessage(vehicle.getCarInfo());
        alertDialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent myIntent = new Intent(CreateVehicleActivity.this, VehiclesActivity.class);
                myIntent.putExtra(MODE, mode.VEHICLES_LIST.name());
                if (SaveData.getSync()) {
                    SendInfoVehicle s = new SendInfoVehicle();
                    s.deleteVehicle(String.valueOf(vehicle.getVehicleId()));
                }
                // delete driver from database
                db.deleteVehicle(String.valueOf(vehicle.getVehicleId()));
                new DatabaseHandlerPasses(context)
                        .deleteRequestVehicleID(String.valueOf(vehicle.getVehicleId()));
                startActivity(myIntent);
                finish();
            }
        });
        alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // Do nothing
            }
        });
        alertDialog.show();
        break;
    default:
        break;
    }
    return true;
}

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

@Override
public void init(Bundle savedInstanceState) {
    setupLayout(R.layout.activity_gpms_login, Color.parseColor("#009688"));
    rollNoEditText = (EditText) findViewById(R.id.roll_no);
    passwordEditText = (EditText) findViewById(R.id.pwd);

    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setMessage("Amrita University does not provide an API for accessing GPMS data. "
            + "So, if any changes are made to the GPMS Website, please be patient while I try to catch up.")
            .setCancelable(true).setIcon(R.drawable.ic_action_info_small)
            .setPositiveButton("Got it !", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();/*from   ww  w. j a  va 2 s  .  c o  m*/
                    hideSoftKeyboard();
                    showConnectToAmritaAlert();
                }
            });
    AlertDialog alert = builder.create();
    alert.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alert.show();

    dialog = new ProgressDialog(baseContext);
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);
    dialog.setInverseBackgroundForced(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setMessage("Authenticating your credentials ... ");
    preferences = getSharedPreferences("gpms_prefs", Context.MODE_PRIVATE);
    String rollNo = preferences.getString("roll_no", "");
    String encodedPassword = preferences.getString("password", "");
    if (!rollNo.equals("")) {
        rollNoEditText.setText(rollNo);
        studentRollNo = rollNo;
        hideSoftKeyboard();
    } else {
        SharedPreferences aumsPrefs = getSharedPreferences("aums_prefs", Context.MODE_PRIVATE);
        String aumsRollNo = aumsPrefs.getString("RollNo", "");
        if (!aumsRollNo.equals("")) {
            rollNoEditText.setText(aumsRollNo);
            studentRollNo = aumsRollNo;
            hideSoftKeyboard();
        }
    }

    if (!encodedPassword.equals("")) {
        passwordEditText.setText(Security.decrypt(encodedPassword, MainApplication.key));
        hideSoftKeyboard();
    }
}

From source file:com.khoahuy.phototag.HomeActivity.java

@Override
protected void processNfcID() {
    if (("").equals(nfcid) || nfcid == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(HomeActivity.this);
        builder.setTitle("Error");
        builder.setMessage("Dected your tag fail");
        builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
            }/*  w w w .  j  ava  2  s .  co m*/
        });
        builder.show();
    } else if (existedUID(nfcid)) {
        displayNFCItem(nfcid);
    } else {
        dispatchTakePictureIntent(ACTION_TAKE_PHOTO_B);
    }
}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

public void showOpenDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(ViewRedditActivity.this);
    builder.setMessage("Open Url").setNegativeButton("Content", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            openUrlExternally(getIntent().getStringExtra(WidgetProvider.ITEM_URL));
        }//  w  ww  . ja  v a 2 s .  com
    }).setPositiveButton("Reddit Page", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            openUrlExternally("http://reddit.com" + getIntent().getStringExtra(WidgetProvider.ITEM_PERMALINK));
        }
    });
    // Create the AlertDialog
    builder.create().show();
}