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.vuze.android.remote.AppPreferences.java

public void showRateDialog(final Activity mContext) {

    if (!shouldShowRatingReminder()) {
        return;/* w w w  . j a v  a2s.co  m*/
    }

    // skip showing if they are adding a torrent (or anything else)
    Intent intent = mContext.getIntent();
    if (intent != null) {
        Uri data = intent.getData();
        if (data != null) {
            return;
        }
    }

    // even if something goes wrong, we want to set that we asked, so
    // it doesn't continue to pop up
    setAskedRating();

    Dialog dialog = new Dialog(mContext);

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage(R.string.ask_rating_message).setCancelable(false)
            .setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final String appPackageName = mContext.getPackageName();
                    try {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("market://details?id=" + appPackageName)));
                    } catch (android.content.ActivityNotFoundException anfe) {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
                    }
                    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskStoreClick",
                            null);
                }
            }).setNeutralButton(R.string.later, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).setNegativeButton(R.string.no_thanks, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    setNeverAskRatingAgain();
                }
            });
    dialog = builder.create();

    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskShown", null);
    dialog.show();
}

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * Performs request for data from the server
 * @param server Server object to populate with data
 *///www.ja  v  a2 s . c  o  m
private void getServerData(Server server) {
    final ProgressDialog dialog = ProgressDialog.show(this, "", "Requesting Server Info", true);
    GetServerDataTask task = new GetServerDataTask(server, new GetServerDataTask.ServerDataResultHandler() {

        @SuppressWarnings("unchecked")
        @Override
        public void onServerDataResult(final Server server, String result) {
            dialog.dismiss();
            if (result == null) {
                serverList.add(server);
                new SaveServerListTask(getApplicationContext()).execute(serverList.getServerList());
                updateListView();
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(MCServerTrackerActivity.this);
                builder.setMessage("Failed to contact server\n" + result);
                builder.setPositiveButton("Try Again", new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        getServerData(server);
                    }
                });
                builder.setNegativeButton("Cancel", new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.setNeutralButton("Back", new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        Intent addServer = new Intent(MCServerTrackerActivity.this, AddServerActivity.class);
                        addServer.putExtra(Server.SERVER_ID, server.id);
                        addServer.putExtra(Server.SERVER_NAME, server.name);
                        addServer.putExtra(Server.SERVER_ADDRESS, server.address);
                        addServer.putExtra(Server.SERVER_PORT, "" + server.port);

                        startActivityForResult(addServer, AddServerActivity.ADD_SERVER_ACTIVITY_ID);
                    }
                });

                builder.create().show();
            }
        }
    });

    task.execute();
}

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

@Override
protected void onListItemClick(ListView l, View v, final int positionItemList, long id) {
    progDialog = new ProgressDialog(this);

    if (adapter.getItem(positionItemList).getResult() != null) {
        Intent intent = new Intent(this, CaptureActivity.class);
        intent.putExtra(Intents.History.ITEM_NUMBER, positionItemList);
        setResult(Activity.RESULT_OK, intent);

        AlertDialog.Builder builder2 = new AlertDialog.Builder(this, 3);
        builder2.setMessage(getBaseContext().getResources().getString(R.string.alerta_enviar_dado));
        builder2.setCancelable(true);//from  w  w w.  j  a  v  a  2  s .c om
        builder2.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i2) {

                /*
                 * mandando somente um dado para o servidor
                 */
                boolean conectado = verificaConexao();
                if (conectado) {
                    try {
                        progDialog.setTitle(
                                getBaseContext().getResources().getString(R.string.alerta_enviando_dado));
                        progDialog.setMessage(
                                getBaseContext().getResources().getString(R.string.alerta_dado_sendo_enviado));
                        progDialog.setIcon(android.R.drawable.ic_menu_upload);
                        progDialog.show();

                        String dado = adapter.getItem(positionItemList).getDisplay();
                        enviarItemHistorico(dado);

                    } catch (Exception ex) {
                        // TODO: handle exception
                        ex.printStackTrace();
                    }
                }
                dialog.dismiss();
                reloadHistoryItems();
            }
        });
        builder2.setNegativeButton(R.string.button_cancel, null);
        builder2.show();

    }

}

From source file:com.sakisds.icymonitor.activities.AddNotificationActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.button_cancel:
        finish();/*from   w w  w .j  a  va  2  s . c  om*/
        break;
    case R.id.button_add:
        addNotification();
        break;
    case R.id.button_notification_help:
        AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);

        dlgAlert.setMessage(getString(R.string.notif_ring_once_help));
        dlgAlert.setPositiveButton("OK", null);
        dlgAlert.setCancelable(true);
        dlgAlert.create().show();
    }
}

From source file:com.jeremyhaberman.playgrounds.Playgrounds.java

/**
 * Display an error about failing to load playground data. Called by
 * displayErrorTask/*from   ww w  . ja va2  s  .  c  om*/
 */
protected void displayLocationError() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // builder.setTitle("ERROR");

    builder.setMessage(getString(R.string.unable_to_get_current_location));
    builder.setCancelable(false);
    builder.setPositiveButton("Try Again", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
            mHandler.post(showPlaygrounds);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog = builder.create();
    alertDialog.show();
    mHandler.sendEmptyMessage(0);
}

From source file:com.jeremyhaberman.playgrounds.Playgrounds.java

/**
 * Display an error about failing to load playground data. Called by
 * displayErrorTask/*from   w ww . j a  v a 2s .c om*/
 */
protected void displayPlaygroundLoadError() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // builder.setTitle("ERROR");

    builder.setMessage("Error loading playgrounds");
    builder.setCancelable(false);
    builder.setPositiveButton("Try Again", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
            mHandler.post(showPlaygrounds);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog = builder.create();
    alertDialog.show();
    mHandler.sendEmptyMessage(0);
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment.java

private void enableGPS() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
    dialog.setTitle("  (GPS) ");

    dialog.setMessage(
            "??   (GPS)  .   (GPS) ? ?");
    dialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent enableGPSIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivityForResult(enableGPSIntent, 1);
        }//  ww w.  j  a  v a  2 s  .  c om
    }).setNegativeButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    }).create().show();
}

From source file:net.openwatch.acluaz.FormFragmentActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    /*/*  w w w  .  j  av  a 2s . co  m*/
       case R.id.menu_clear_personal:
     AlertDialog.Builder builder = new AlertDialog.Builder(this);
     builder.setTitle(getString(R.string.clear_personal_info_dialog_title))
     .setMessage(getString(R.string.clear_personal_info_dialog_msg))
     .setPositiveButton(getString(R.string.clear_personal_info_ok_btn), new OnClickListener(){
            
       @Override
       public void onClick(DialogInterface dialog, int which) {
          SharedPreferencesManager.clearPrefsAndForm(FormFragmentActivity.this, getPersonalFormFragment(), Constants.PERSONAL_PREFS);
          dialog.dismiss();
       }
                
     }).setNegativeButton(getString(R.string.clear_personal_info_cancel_btn), new OnClickListener(){
            
       @Override
       public void onClick(DialogInterface dialog, int which) {
          dialog.dismiss();
       }
                
     }).show();
             
     break;
    */
    case R.id.menu_submit_form:
        if (!validateFormFragments()) {
            showFormIncompleteDialog();
            break;
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(FormFragmentActivity.this);
        builder.setMessage(getString(R.string.form_disclaimer))
                .setPositiveButton(getString(R.string.dialog_submit), new OnClickListener() {

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

                }).setNegativeButton(getString(R.string.dialog_cancel), new OnClickListener() {

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

                }).show();
        break;
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        break;
    }
    return true;
}

From source file:net.openwatch.acluaz.FormFragmentActivity.java

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

    setContentView(R.layout.fragment_tabs_pager);
    // Show the Up button in the action bar.
    this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getDisplayWidth();/*w ww  .  j a  va 2 s .c o  m*/
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.personal_tab)).setIndicator(
            inflateCustomTab(getString(R.string.personal_tab))), PersonalFormFragment.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.incident_tab)).setIndicator(
            inflateCustomTab(getString(R.string.incident_tab))), IncidentFormFragment.class, null);

    /*
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.personal_tab)).setIndicator(inflateCustomTab(getString(R.string.personal_tab))),
        PersonalFormFragment.class, null);
            
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.event_tab)).setIndicator(inflateCustomTab(getString(R.string.event_tab))),
        RemoteFeedFragmentActivity.RemoteRecordingsListFragment.class, null);
    */
    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
    }

    DeviceLocation location = new DeviceLocation();
    location.getLocation(getApplicationContext(), new LocationResult() {

        @Override
        public void gotLocation(Location location) {
            if (FormFragmentActivity.this != null
                    && FormFragmentActivity.this.findViewById(R.id.gps_toggle) != null) {
                FormFragmentActivity.this.findViewById(R.id.gps_toggle).setTag(R.id.view_tag, location);
                //Log.i(TAG, "Tagged location_input with : " + FormFragmentActivity.this.findViewById(R.id.gps_toggle).getTag(R.id.view_tag).toString());
            }
        }

    }, true);

    Intent i = getIntent();
    if (!i.hasExtra(Constants.INTERNAL_DB_ID)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(FormFragmentActivity.this);
        builder.setMessage(getString(R.string.pre_form_disclaimer))
                .setPositiveButton(getString(R.string.dialog_ok), new OnClickListener() {

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

                }).show();
    }
}

From source file:ota.otaupdates.MainActivity.java

private void trigger_autoinstall(final String file_path) {
    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    final CoordinatorLayout coordinator_root = (CoordinatorLayout) findViewById(R.id.coordinator_root);
    if (sharedPreferences.getBoolean("enable_auto_install", true)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.auto_install_title));
        builder.setMessage(getString(R.string.auto_install_message));
        builder.setPositiveButton(getString(R.string.button_yes), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                if (Shell.SU.available()) {
                    Shell.SU.run("rm -rf /cache/recovery/openrecoveryscript");
                    Shell.SU.run("echo \"install " + file_path + "\" >> /cache/recovery/openrecoveryscript");

                    if (sharedPreferences.getBoolean("wipe_cache", true))
                        Shell.SU.run("echo \"wipe cache\" >> /cache/recovery/openrecoveryscript");

                    if (sharedPreferences.getBoolean("wipe_dalvik", true))
                        Shell.SU.run("echo \"wipe dalvik\" >> /cache/recovery/openrecoveryscript");

                    if (sharedPreferences.getBoolean("auto_reboot", true))
                        Shell.SU.run("reboot recovery");
                } else {
                    sb_no_su = Snackbar.make(coordinator_root, "SU access is not available",
                            Snackbar.LENGTH_SHORT);
                    sb_no_su.getView()/* w  w  w. j a va 2 s . c o m*/
                            .setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorSecond));
                    sb_no_su.show();
                }
            }
        });
        builder.setNegativeButton(getString(R.string.button_no), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        AlertDialog alert = builder.create();
        alert.setCancelable(false);
        alert.show();
    }
}