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.sakisds.icymonitor.activities.ConnectionActivity.java

void showErrorDialog(int title, int message) {
    AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
    dlgAlert.setTitle(getResources().getString(title));
    dlgAlert.setMessage(getResources().getString(message));
    dlgAlert.setPositiveButton("OK", null);
    dlgAlert.setCancelable(true);//from   www. j  a  va  2s  . c  o m
    dlgAlert.create().show();
}

From source file:com.glabs.homegenie.widgets.MediaServerDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    _view = getActivity().getLayoutInflater().inflate(R.layout.widget_control_mediaserver, null);
    builder.setView(_view);/* w w w  . j  a v  a 2 s.c  o m*/

    builder.setMessage(_module.getDisplayName())
            .setPositiveButton("Play", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // Play to...
                    playMediaTo();
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // User cancelled the dialog
                }
            });

    mAdapter = new MediaFilesAdapter(_view.getContext(), R.layout.widget_control_mediaserver_item,
            new ArrayList<MediaEntry>());
    final ListView lv = (ListView) _view.findViewById(R.id.filesList);
    lv.setAdapter(mAdapter);
    //
    if (navigationStack.size() == 0) {
        navigationStack.add("0");
    }
    //
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            MediaEntry clicked = mAdapter.getItem(i);
            mAdapter.setSelectedIndex(i);
            _selectedMedia = null;
            //
            if (clicked.Class.indexOf("object.container") == 0) {
                // browse to folder
                _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
                if (clicked.Title.equals(PARENT_FOLDER)) {
                    navigationStack.removeLast();
                } else {
                    navigationStack.add(clicked.Id);
                }
                browseMediaFolder(lv);
            } else {
                // set current media file
                _selectedMedia = clicked;
                _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
            }
        }
    });
    //

    Control.getGroupModules("", new Control.GetGroupModulesCallback() {
        @Override
        public void groupModulesUpdated(ArrayList<Module> modules) {
            ArrayAdapter<CharSequence> playtoitems = new ArrayAdapter<CharSequence>(_view.getContext(),
                    android.R.layout.simple_spinner_item);
            //
            playtoitems.add("This device");
            //
            for (int m = 0; m < modules.size(); m++) {
                Module module = modules.get(m);
                ModuleParameter devtype = module.getParameter("UPnP.StandardDeviceType");
                if (devtype != null && devtype.Value.equals("MediaRenderer")) {
                    renderers.add(module);
                    playtoitems.add(Control.getUpnpDisplayName(module));
                }
            }
            //
            // Media Renderer Spinner Select
            Spinner playto = (Spinner) _view.findViewById(R.id.playto);
            playto.setAdapter(playtoitems);
            playto.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    _selectedMediaRender = null;
                    if (i > 0) {
                        _selectedMediaRender = renderers.get(i - 1);
                    }
                }

                @Override
                public void onNothingSelected(AdapterView<?> adapterView) {

                }
            });

        }
    });
    //
    browseMediaFolder(lv);

    // Create the AlertDialog object and return it
    _dialog = builder.create();
    _dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
        }
    });
    return _dialog;
}

From source file:com.ritul.truckshare.RegisterActivity.DriverLicenseActivity.java

public void Image_Picker_Dialog() {

    AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
    myAlertDialog.setTitle("Pictures Option");
    myAlertDialog.setMessage("Select Picture Mode");

    myAlertDialog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            /* Utility.pictureActionIntent = new Intent(Intent.ACTION_GET_CONTENT, null);
             Utility.pictureActionIntent.setType("image*//*");
                                                          Utility.pictureActionIntent.putExtra("return-data", true);
                                                          startActivityForResult(Utility.pictureActionIntent, Utility.GALLERY_PICTURE);*/
            Intent i7 = new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i7, Utility.GALLERY_PICTURE);
        }/*from w ww  . j av  a2  s.  c om*/
    });

    myAlertDialog.setNegativeButton("Camera", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            /*Utility.pictureActionIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(Utility.pictureActionIntent, Utility.CAMERA_PICTURE);*/

            Intent cameraIntent1 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent1, Utility.CAMERA_PICTURE);

        }
    });
    myAlertDialog.show();

}

From source file:com.ts.mobilelab.goggles4u.PrescriptionAddActivity.java

public static void show_dialog(Context cxt, String msg) {

    final AlertDialog.Builder alert = new AlertDialog.Builder(cxt);
    alert.setMessage(msg);
    alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override//from www. j  a  v a  2 s . c o m
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

        }
    });
    alert.show();

}

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

public void enviaTodosDados() {
    /*/*w  w  w  .  j ava  2  s. c om*/
     * enviar todos os qr's lidos
     */

    AlertDialog.Builder builder1 = new AlertDialog.Builder(this, 3);
    builder1.setMessage(R.string.enviar_todos);
    builder1.setCancelable(true);
    builder1.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i2) {

            boolean conectado = verificaConexao();
            if (conectado) {
                try {
                    progDialog.setTitle(R.string.alerta_enviando_dados);
                    progDialog.setMessage(
                            getBaseContext().getResources().getString(R.string.alerta_dados_sendo_enviados));
                    progDialog.setIcon(android.R.drawable.ic_menu_upload);
                    progDialog.show();
                    enviarListaHistorico();

                } catch (Exception e) {
                    // TODO: handle exception
                    progDialog.setIcon(android.R.drawable.ic_dialog_alert);
                    progDialog.setTitle(R.string.alerta_erro);
                    progDialog.setMessage(
                            getBaseContext().getResources().getString(R.string.alerta_erro_ao_enviar_dados)
                                    + " - " + e.getMessage());
                    progDialog.dismiss();
                }
            }
            dialog.dismiss();
        }
    });

    builder1.setNegativeButton(R.string.button_cancel, null);
    builder1.show();
}

From source file:info.snowhow.plugin.RecorderService.java

private void showNoGPSAlert() {
    Log.i(LOG_TAG, "No GPS available --- show Dialog");
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setMessage("GPS is disabled on your device. Would you like to enable it?")
            .setCancelable(false).setPositiveButton("GPS Settings", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent callGPSSettingIntent = new Intent(
                            android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    callGPSSettingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(callGPSSettingIntent);
                }/*from   w w  w .j av a2  s .c  o m*/
            });
    alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            stopRecording();
            dialog.cancel();
        }
    });
    AlertDialog alert = alertDialogBuilder.create();
    alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    alert.show();
}

From source file:kn.uni.gis.foxhunt.GameActivity.java

@Override
public void onBackPressed() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(false);/* w w w.j ava  2s.  co m*/
    builder.setMessage(getString(R.string.GAME_BACK_DESC));
    builder.setTitle(getString(R.string.GAME_BACK_TITLE));
    builder.setNegativeButton(R.string.GAME_BACK_OK, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            GameActivity.this.finish();
        }
    }).setPositiveButton(getString(R.string.GAME_BACK_CANCEL), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // NOOP
        }
    }).create().show();
}

From source file:net.hockeyapp.android.internal.CheckUpdateTask.java

private void showDialog(final JSONArray updateInfo) {
    if (getCachingEnabled()) {
        VersionCache.setVersionInfo(activity, updateInfo.toString());
    }/*w  ww.  java  2  s .  c  o  m*/

    if ((activity == null) || (activity.isFinishing())) {
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(Strings.get(listener, Strings.UPDATE_DIALOG_TITLE_ID));

    if (!mandatory) {
        builder.setMessage(Strings.get(listener, Strings.UPDATE_DIALOG_MESSAGE_ID));

        builder.setNegativeButton(Strings.get(listener, Strings.UPDATE_DIALOG_NEGATIVE_BUTTON_ID),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        cleanUp();
                    }
                });

        builder.setPositiveButton(Strings.get(listener, Strings.UPDATE_DIALOG_POSITIVE_BUTTON_ID),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (getCachingEnabled()) {
                            VersionCache.setVersionInfo(activity, "[]");
                        }

                        if ((UpdateManager.fragmentsSupported()) && (UpdateManager.runsOnTablet(activity))) {
                            showUpdateFragment(updateInfo);
                        } else {
                            startUpdateIntent(updateInfo, false);
                        }
                    }
                });

        builder.create().show();
    } else {
        Toast.makeText(activity, Strings.get(listener, Strings.UPDATE_MANDATORY_TOAST_ID), Toast.LENGTH_LONG)
                .show();
        startUpdateIntent(updateInfo, true);
    }
}

From source file:com.example.survey2.ExpandableListAdapter.java

public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        final ViewGroup parent) {
    View v;//w  w  w  .j a  va  2s. c o m

    if (convertView == null) {
        v = newChildView(isLastChild, parent);
        Button webButton = (Button) v.findViewById(R.id.webButton);

        webButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                String url = mChildData.get(SuggestionList.groupPosition).get(0).get("url").toString();
                String suggestionId = mChildData.get(SuggestionList.groupPosition).get(0).get("id").toString();
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("name", "website_click_" + suggestionId));
                params.add(new BasicNameValuePair("value", "1"));
                new SuggestionList().new postData().execute(params);

                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                mContext.startActivity(browserIntent);
            }
        });

        Button likeButton = (Button) v.findViewById(R.id.likeButton);
        likeButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View button) {
                mGroupViews.add(SuggestionList.groupPosition);
                button.setEnabled(false);

                //         parent.setBackgroundColor(Color.GREEN);

                String suggestionId = mChildData.get(SuggestionList.groupPosition).get(0).get("id").toString();
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("name", "suggestion_select_" + suggestionId));
                params.add(new BasicNameValuePair("value", "1"));
                new SuggestionList().new postData().execute(params);
                //               
                SuggestionList.numBookmarked++;
                if (SuggestionList.numBookmarked < SuggestionList.MIN_BOOKMARKED) {
                    Toast.makeText(mContext, R.string.bookmark, Toast.LENGTH_SHORT).show();
                } else {
                    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                    builder.setMessage(R.string.bookmark);
                    if (DisplayContext.contextIndex < DisplayContext.numContexts) {
                        builder.setPositiveButton("Select new city", new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                SuggestionList.numBookmarked = 0;
                                Intent intent = new Intent(mContext, DisplayContext.class);
                                //                           intent.putExtra(EXTRA_USERID, SuggestionList.userid);
                                intent.putExtra(DisplayContext.EXTRA_CONTEXT, DisplayContext.contextIndex + 1);
                                mContext.startActivity(intent);

                            }
                        });
                    } else {
                        builder.setPositiveButton("Finish", new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent intent = new Intent(mContext, Finish.class);
                                mContext.startActivity(intent);

                            }
                        });
                    }
                    // If all the suggestions have been selected, only display the 
                    // 'Select next city' button.
                    if (SuggestionList.numBookmarked < getGroupCount()) {
                        builder.setNegativeButton("Continue", new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                    }

                    builder.create().show();
                }

            }
        });

    } else {
        v = convertView;
    }
    bindView(v, mChildData.get(groupPosition).get(childPosition), mChildFrom, mChildTo);
    mChildViews.put(groupPosition, v);
    return v;
}

From source file:com.spoiledmilk.ibikecph.favorites.EditFavoriteFragment.java

private void launchErrorDialog(final String msg) {
    if (getActivity() != null && getView() != null) {
        getActivity().runOnUiThread(new Runnable() {

            @Override//from   w  ww . j a  v a 2s  . co  m
            public void run() {
                getView().findViewById(R.id.progress).setVisibility(View.INVISIBLE);
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle("Error");
                builder.setMessage(msg);
                builder.setPositiveButton(IbikeApplication.getString("ok"),
                        new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();

                            }
                        });
                dialog2 = builder.show();
            }
        });
    }

}