Example usage for android.app AlertDialog.Builder show

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

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.chaosinmotion.securechat.fragments.OnboardingCreateAccount.java

@Override
public void doNext() {
    String uname = username.getText().toString();
    String pwd = password.getText().toString();
    if (!PasswordComplexity.complexityTest(pwd)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.weak_password_message);
        builder.setTitle(R.string.weak_password_title);
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override//www . j  a v  a2  s .  c  om
            public void onClick(DialogInterface dialog, int which) {
                // Ignore
            }
        });
        builder.show();
    }

    final SCNetworkCredentials creds = new SCNetworkCredentials(uname);
    creds.setPasswordFromClearText(pwd);

    try {
        JSONObject json = new JSONObject();
        json.put("username", creds.getUsername());
        json.put("password", creds.getPassword());
        json.put("deviceid", SCRSAManager.shared().getDeviceUUID());
        json.put("pubkey", SCRSAManager.shared().getPublicKey());

        SCNetwork.get().request("login/createaccount", json, this, new SCNetwork.ResponseInterface() {
            @Override
            public void responseResult(SCNetwork.Response response) {
                if (response.isSuccess()) {
                    /*
                     *  Success. Save the username and password,
                     *  and save the whole thing to the back end.
                     */
                    SCRSAManager.shared().setCredentials(creds.getUsername(), creds.getPassword());
                    SCRSAManager.shared().encodeSecureData(getActivity());

                    /*
                     *  We have what we need to start the queue
                     */
                    SCMessageQueue.get().startQueue(getActivity());

                    /*
                     *  Done. Go to the next page
                     */

                    wizardInterface.transitionToFragment(new OnboardingFinished());
                }
            }
        });
    } catch (JSONException ex) {
    }
}

From source file:com.chaosinmotion.securechat.fragments.ChangePasswordStart.java

@Override
public void doNext() {
    String password = newPassword.getText().toString();
    if (!PasswordComplexity.complexityTest(password)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.weak_password_message);
        builder.setTitle(R.string.weak_password_title);
        builder.setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override/*from ww w  . ja va 2 s .co  m*/
            public void onClick(DialogInterface dialog, int which) {
                // Ignore
            }
        });
        builder.show();
        return;
    }

    String retypedPassword = copyPassword.getText().toString();
    if (!retypedPassword.equals(password)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.change_password_not_matched_message);
        builder.setTitle(R.string.change_password_not_matched_title);
        builder.setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // Ignore
            }
        });
        builder.show();
        return;
    }

    changePassword(oldPassword.getText().toString(), password);
}

From source file:fr.gcastel.freeboxV6GeekIncDownloader.services.FreeboxDownloaderService.java

private void showAlertDialog() {
    AlertDialog.Builder alertbox = new AlertDialog.Builder(zeContext);
    alertbox.setMessage(alertDialogMessage);
    alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            dialogueEnCours = DialogEnCours.NONE;
            return;
        }//from w w w.  ja va 2  s  . com
    });
    alertbox.show();
}

From source file:com.intel.xdk.notification.Notification.java

public void alert(String message, String title, String button) {
    if (button == null || button.length() == 0 || button.equals("undefined"))
        button = "OK";
    AlertDialog.Builder alertBldr = new AlertDialog.Builder(activity);
    alertBldr.setMessage(message);/*from  www . j  a va2  s. com*/
    alertBldr.setTitle((title == null || title.length() == 0 || title.equals("undefined")) ? "Alert" : title);
    alertBldr.setPositiveButton(button, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    alertBldr.show();
}

From source file:net.naonedbus.activity.impl.CommentaireActivity.java

/**
 * Afficher une dialog de selection./*from w  w  w.  jav  a2  s.  com*/
 * 
 * @param title
 *            Le titre
 * @param adapter
 *            L'adapter
 * @param defaultPosition
 *            La position de l'lment slectionn par dfaut
 * @param onClickListener
 *            Le callback
 */
private void showSelectDialog(final int title, final ListAdapter adapter, final int defaultPosition,
        final DialogInterface.OnClickListener onClickListener) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title);
    builder.setSingleChoiceItems(adapter, defaultPosition, onClickListener);
    builder.show();
}

From source file:app.wz.MainActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.menu_run_pause) {
        if (neuro.halt) {
            neuro.halt = false;/*ww w .j a v a 2s.c om*/
            setProgressBarIndeterminateVisibility(true);

            wakeLock.acquire();

            if (prefs.getBoolean("use_server", false))
                lock.acquire();

            // for the system's orientation sensor registered listeners
            mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
                    SensorManager.SENSOR_DELAY_GAME);

            synchronized (neuro) {
                neuro.notify();
            }
        } else {

            haltNeuro();
        }
    } else {
        if (!neuro.halt) {
            haltNeuro();
        }
    }

    if (id == R.id.menu_device_connect) {
        bt.setDeviceTarget(BluetoothState.DEVICE_OTHER);
        /*
        if(bt.getServiceState() == BluetoothState.STATE_CONNECTED)
         bt.disconnect();*/
        Intent intent = new Intent(getApplicationContext(), DeviceList.class);
        startActivityForResult(intent, BluetoothState.REQUEST_CONNECT_DEVICE);
    } else if (id == R.id.reset_Neuro) {
        neuro.updatePrefs(true);
        textRead.append("Reset Neuro \n");
        textScroll.fullScroll(View.FOCUS_DOWN);
    } else if (id == R.id.menu_disconnect) {
        if (bt.getServiceState() == BluetoothState.STATE_CONNECTED)
            bt.disconnect();
    } else if (id == R.id.remote_control) {
        if (bt.getServiceState() == BluetoothState.STATE_CONNECTED) {
            Intent intent = new Intent(this, JoystickActivity.class);
            startActivity(intent);
        } else {
            Toast.makeText(getApplicationContext(), "Not Connected", Toast.LENGTH_SHORT).show();
        }
        return true;
    } else if (id == R.id.action_settings) {
        Intent intent = new Intent(this, SettingsActivity.class);
        startActivity(intent);
        return true;
    } else if (id == R.id.help) {
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.help, null);
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setView(view);
        alert.show();
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.vishnuvalleru.travelweatheralertsystem.MainActivity.java

private void showAlert(String title, String message) {
    AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
    alert.setTitle(title);//  w  ww  .j av  a  2s .c o m
    alert.setCancelable(false);
    alert.setMessage(message);
    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    alert.show();
}

From source file:at.alladin.rmbt.android.about.RMBTAboutFragment.java

private View createView(View view, LayoutInflater inflater) {
    activity = getActivity();//from   ww w.  j a  v  a 2  s  . c o m

    getAppInfo(activity);

    final String clientUUID = String.format("U%s", ConfigHelper.getUUID(activity.getApplicationContext()));

    final String controlServerVersion = ConfigHelper.getControlServerVersion(activity);

    final ListView listView = (ListView) view.findViewById(R.id.aboutList);

    final ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    HashMap<String, String> item;
    item = new HashMap<String, String>();
    item.put("title", clientName);
    item.put("text1", this.getString(R.string.about_rtr_line1));
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", this.getString(R.string.about_version_title));
    item.put("text1", clientVersion);
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_clientid_title));
    item.put("text1", clientUUID);
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_web_title));
    item.put("text1", getString(R.string.about_web_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_email_title));
    item.put("text1", getString(R.string.about_email_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_terms_title));
    item.put("text1", getString(R.string.about_terms_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_git_title));
    item.put("text1", getString(R.string.about_git_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_dev_title));
    item.put("text1", getString(R.string.about_dev_line1));
    item.put("text2", getString(R.string.about_dev_line2));
    list.add(item);

    final String openSourceSoftwareLicenseInfo = GooglePlayServicesUtil
            .getOpenSourceSoftwareLicenseInfo(getActivity());

    if (openSourceSoftwareLicenseInfo != null) {
        item = new HashMap<String, String>();
        item.put("title", getString(R.string.about_gms_legal_title));
        item.put("text1", getString(R.string.about_gms_legal_line1));
        item.put("text2", "");
        list.add(item);
    }

    if (ConfigHelper.isDevEnabled(getActivity())) {
        item = new HashMap<String, String>();
        item.put("title", getString(R.string.about_test_counter_title));
        item.put("text1", Integer.toString(ConfigHelper.getTestCounter(getActivity())));
        item.put("text2", "");
        list.add(item);
    }

    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_control_server_version));
    item.put("text1", controlServerVersion != null ? controlServerVersion : "---");
    item.put("text2", "");
    list.add(item);

    sa = new RMBTAboutAdapter(getActivity(), list, R.layout.about_item,
            new String[] { "title", "text1", "text2" }, new int[] { R.id.title, R.id.text1, R.id.text2 });

    listView.setAdapter(sa);

    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> l, final View v, final int position, final long id) {

            switch (position) {

            case 1:
                handleHiddenCode();
                break;

            case 2:
                final android.content.ClipboardManager clipBoard = (android.content.ClipboardManager) getActivity()
                        .getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("client_uuid", clientUUID);
                clipBoard.setPrimaryClip(clip);
                final Toast toast = Toast.makeText(getActivity(), R.string.about_clientid_toast,
                        Toast.LENGTH_LONG);
                toast.show();
                break;

            case 3:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_web_link))));
                break;

            case 4:
                /* Create the Intent */
                final Intent emailIntent = new Intent(Intent.ACTION_SEND);

                /* Fill it with Data */
                emailIntent.setType("plain/text");
                emailIntent.putExtra(Intent.EXTRA_EMAIL,
                        new String[] { getString(R.string.about_email_email) });
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.about_email_subject));
                emailIntent.putExtra(Intent.EXTRA_TEXT, "");

                /* Send it off to the Activity-Chooser */
                startActivity(Intent.createChooser(emailIntent, getString(R.string.about_email_sending)));

                break;

            case 5:
                final FragmentManager fm = activity.getSupportFragmentManager();
                FragmentTransaction ft;
                ft = fm.beginTransaction();
                ft.replace(R.id.fragment_content, new RMBTTermsFragment(), "terms");
                ft.addToBackStack("terms");
                ft.commit();
                break;

            case 6:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_git_link))));
                break;

            case 7:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_dev_link))));
                break;

            case 8:
                final String licenseInfo = GooglePlayServicesUtil
                        .getOpenSourceSoftwareLicenseInfo(getActivity());
                AlertDialog.Builder licenseDialog = new AlertDialog.Builder(getActivity());
                licenseDialog.setMessage(licenseInfo);
                licenseDialog.show();
                break;

            default:
                break;
            }
        }

    });

    return view;
}

From source file:ca.ualberta.cs.drivr.GPSTracker.java

/**
 * Opens settings Activity to allow user to turn on GPS.
 *///www.  j  ava 2s.  c om
public void enableGPS() {
    AlertDialog.Builder GPSDialog = new AlertDialog.Builder(mContext);

    GPSDialog.setTitle("Please turn on Location Settings");
    GPSDialog.setMessage("GPS and/or A Network Provider is Required");

    GPSDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
        }
    });
    GPSDialog.show();
}

From source file:com.chaosinmotion.securechat.fragments.OnboardingForgotPassword.java

private void doResetPassword() {
    try {/*from   w  w  w  . ja va2s.c  o  m*/
        JSONObject d = new JSONObject();
        d.put("username", username.getText().toString());
        SCNetwork.get().request("login/forgotpassword", d, this, new SCNetwork.ResponseInterface() {
            @Override
            public void responseResult(SCNetwork.Response response) {
                if (response.isSuccess()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                    builder.setMessage(R.string.reset_password_message);
                    builder.setTitle(R.string.reset_password_title);
                    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            wizardInterface.goBack();
                        }
                    });
                    builder.show();
                }
            }
        });
    } catch (JSONException ex) {
    }
}