Example usage for android.app AlertDialog.Builder create

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

Introduction

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

Prototype

public void create() 

Source Link

Document

Forces immediate creation of the dialog.

Usage

From source file:com.nextgis.maplibui.dialog.CreateFromQMSLayerDialog.java

@NonNull
@Override/*ww  w  .j a va  2 s.  c  o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    mNet = new NetworkUtil(mContext);
    mQMSIconsDir = MapUtil.prepareTempDir(mContext, "qms_icons");

    if (null != savedInstanceState) {
        int id = savedInstanceState.getInt(KEY_ID);
        MapBase map = MapBase.getInstance();
        if (null != map) {
            ILayer iLayer = map.getLayerById(id);
            if (iLayer instanceof LayerGroup) {
                mGroupLayer = (LayerGroup) iLayer;
            }
        }
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle(mTitle).setView(R.layout.list_content).setPositiveButton(R.string.add, null)
            .setNeutralButton(R.string.new_tms, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    CreateRemoteTMSLayerDialog newFragment = new CreateRemoteTMSLayerDialog();
                    newFragment.setLayerGroup(mGroupLayer)
                            .setTitle(mContext.getString(R.string.create_tms_layer))
                            .setTheme(((NGActivity) getActivity()).getThemeId())
                            .show(getActivity().getSupportFragmentManager(), "create_tms_layer");
                }
            }).setNegativeButton(R.string.cancel, null);

    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    mData = new ArrayList<>();
    mChecked = new ArrayList<>();

    IGISApplication application = (IGISApplication) getActivity().getApplication();
    application.sendScreen(ConstantsUI.GA_DIALOG_QMS);
    return dialog;
}

From source file:com.abc.driver.PersonalActivity.java

public void updateIdentityImage(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(res.getString(R.string.choose_portrait));
    builder.setItems(new String[] { res.getString(R.string.getPhotoFromCamera),
            res.getString(R.string.getPhotoFromMemory) }, new DialogInterface.OnClickListener() {
                // @Override
                public void onClick(DialogInterface dialog, int id) {
                    switch (id) {
                    case 0:
                        startToCameraActivity(CellSiteConstants.TAKE_IDENTITY);
                        break;
                    case 1:
                        startToMediaActivity(CellSiteConstants.PICK_IDENTITY);
                        break;
                    }/*from  w  w w  .  ja  v a2s  .  c om*/
                }

            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.spydiko.rotationmanager.MainActivity.java

public void showPlayStoreDialog(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // Add the buttons
    builder.setTitle("Spydiko");
    builder.setMessage(R.string.landing_msg);
    builder.setIcon(R.drawable.icon);//  w  ww  . j  av  a  2s  .co  m
    builder.setPositiveButton(R.string.playStore, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User clicked OK button
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://search?q=pub:Spydiko"));
            startActivity(intent);
        }
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User cancelled the dialog
        }
    });
    // Set other dialog properties

    // Create the AlertDialog
    AlertDialog dialog = builder.create();
    //      AppSpecificOrientation.ALREADY_SHOWED = true;
    //      AppSpecificOrientation.RETURN_FROM_ABOUT = false;
    dialog.show();
}

From source file:com.google.android.apps.paco.ExploreDataActivity.java

private View renderMultiSelectListButton(final Long id, final TextView textview) {

    DialogInterface.OnMultiChoiceClickListener multiselectListDialogListener = new DialogInterface.OnMultiChoiceClickListener() {
        @Override/*  ww w .j  ava2s .com*/
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                if (checkedChoices.get(id) != null) {
                    checkedChoices.get(id).add(inputIds.get(which));
                } else {
                    List<Long> tempList = new ArrayList<Long>();
                    tempList.add(inputIds.get(which));
                    checkedChoices.put(id, tempList);
                }
            } else {
                checkedChoices.get(id).remove(inputIds.get(which));
                if (checkedChoices.get(id).isEmpty())
                    checkedChoices.remove(id);
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(mainLayout.getContext());
    builder.setTitle(R.string.make_selections);

    boolean[] checkedChoicesBoolArray = new boolean[inputIds.size()];
    int count = inputIds.size();

    if (checkedChoices.get(id) != null) {
        for (int i = 0; i < count; i++) {
            checkedChoicesBoolArray[i] = checkedChoices.get(id).contains(inputIds.get(i));
        }
    }
    String[] listChoices = new String[inputIds.size()];
    inpNames.toArray(listChoices);
    builder.setMultiChoiceItems(listChoices, checkedChoicesBoolArray, multiselectListDialogListener);
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            getLabelWithSelectedVariables(id, textview);
        }
    });
    AlertDialog multiSelectListDialog = builder.create();
    multiSelectListDialog.show();
    return multiSelectListDialog.getListView();
}

From source file:com.abc.driver.PersonalActivity.java

public void updatePortait(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(res.getString(R.string.choose_portrait));
    builder.setItems(new String[] { res.getString(R.string.getPhotoFromCamera),
            res.getString(R.string.getPhotoFromMemory) }, new DialogInterface.OnClickListener() {
                // @Override
                public void onClick(DialogInterface dialog, int id) {
                    switch (id) {
                    case 0:
                        startToCameraActivity(CellSiteConstants.TAKE_USER_PORTRAIT);
                        break;
                    case 1:
                        startToMediaActivity(CellSiteConstants.PICK_USER_PORTRAIT);
                        break;
                    }//from ww  w  . j a v  a  2s .  c om
                }

            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.abc.driver.PersonalActivity.java

public void updateDriverLicense(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(res.getString(R.string.choose_portrait));
    builder.setItems(new String[] { res.getString(R.string.getPhotoFromCamera),
            res.getString(R.string.getPhotoFromMemory) }, new DialogInterface.OnClickListener() {
                // @Override
                public void onClick(DialogInterface dialog, int id) {
                    switch (id) {
                    case 0:
                        startToCameraActivity(CellSiteConstants.TAKE_DRIVER_LICENSE);
                        break;
                    case 1:
                        startToMediaActivity(CellSiteConstants.PICK_DRIVER_LICENSE);
                        break;
                    }/* w  w w .  j  av  a2s. c o m*/
                }

            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.nps.micro.view.TestsSectionFragment.java

@Override
protected View buildRootView(LayoutInflater inflater, ViewGroup container) {
    View rootView = inflater.inflate(layout, container, false);

    runButton = (Button) rootView.findViewById(R.id.runButton);
    runButton.setOnClickListener(new OnClickListener() {
        @Override//from   w  w w .  j  av a 2  s.c o m
        public void onClick(View v) {
            prepareScenarios();
        }
    });

    repeatsInput = (EditText) rootView.findViewById(R.id.repeatsInput);
    repeatsInput.setText(String.valueOf(model.getRepeats()));
    repeatsInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            String val = s.toString();
            if (!val.isEmpty() && StringUtils.isNumeric(val)) {
                model.setRepeats(Integer.valueOf(s.toString()));
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    repeatsButton = (Button) rootView.findViewById(R.id.setRepeatsButton);
    repeatsButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(R.string.repeats).setItems(R.array.repeats_array,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            repeatsInput.setText(getResources().getStringArray(R.array.repeats_array)[which]);
                            dialog.dismiss();
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
        }
    });

    outSizeInput = (EditText) rootView.findViewById(R.id.packetOutSizeInput);
    outSizeInput.setText(String.valueOf(model.getStreamOutSize()));
    outSizeInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            String val = s.toString();
            if (!val.isEmpty() && StringUtils.isNumeric(val)) {
                model.setStreamOutSize(Short.valueOf(s.toString()));
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    outSizeButton = (Button) rootView.findViewById(R.id.setOutSizeButton);
    outSizeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(R.string.out_size).setItems(R.array.out_size_array,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            outSizeInput.setText(getResources().getStringArray(R.array.out_size_array)[which]);
                            dialog.dismiss();
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
        }
    });

    inSizeInput = (EditText) rootView.findViewById(R.id.packetInSizeInput);
    inSizeInput.setText(String.valueOf(model.getStreamInSizes()[0]));
    inSizeInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            String[] vals = s.toString().split(" ");
            List<Short> intVals = new ArrayList<Short>();
            for (String val : vals) {
                try {
                    intVals.add(Short.valueOf(val));
                } catch (NumberFormatException e) {
                    // TODO Auto-generated catch block
                }
            }
            short[] array = new short[intVals.size()];
            for (int i = 0; i < intVals.size(); i++)
                array[i] = intVals.get(i);
            model.setStreamInSize(array);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    inSizeButton = (Button) rootView.findViewById(R.id.setInSizeButton);
    inSizeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(R.string.in_size).setItems(R.array.in_size_array,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            inSizeInput.setText(getResources().getStringArray(R.array.in_size_array)[which]);
                            dialog.dismiss();
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
        }
    });

    radioStorageGroup = (RadioGroup) rootView.findViewById(R.id.storageRadioGroup);
    externalStorageRadio = (RadioButton) rootView.findViewById(R.id.externalStorageRadio);
    internalStorageRadio = (RadioButton) rootView.findViewById(R.id.internalStorageRadio);
    switch (model.getStorageType()) {
    case EXTERNAL:
        externalStorageRadio.setChecked(true);
        break;
    case INTERNAL:
        internalStorageRadio.setChecked(true);
        break;
    }
    externalStorageRadio.setEnabled(model.isSaveStreams() || model.isSaveLogs());
    internalStorageRadio.setEnabled(model.isSaveStreams() || model.isSaveLogs());

    radioStorageGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
            case R.id.internalStorageRadio:
                model.setStorageType(Storage.Type.INTERNAL);
                break;
            case R.id.externalStorageRadio:
                model.setStorageType(Storage.Type.EXTERNAL);
                break;
            }
        }
    });

    saveLogsCheckBox = (CheckBox) rootView.findViewById(R.id.saveLogsCheckBox);
    saveLogsCheckBox.setChecked(model.isSaveLogs());
    saveLogsCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setSaveLogs(isChecked);
            externalStorageRadio.setEnabled(model.isSaveStreams() || model.isSaveLogs());
            internalStorageRadio.setEnabled(model.isSaveStreams() || model.isSaveLogs());

        }
    });

    streamBufferSizeInput = (EditText) rootView.findViewById(R.id.bufferSizeEditText);
    streamBufferSizeInput.setText(String.valueOf(model.getStreamBufferSize()));
    streamBufferSizeInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            String val = s.toString();
            if (!val.isEmpty() && StringUtils.isNumeric(val)) {
                model.setStreamBufferSize(Integer.valueOf(s.toString()));
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    memoryUnitSpinner = (Spinner) rootView.findViewById(R.id.memoryUnitSpinner);
    memoryUnitSpinner.setSelection(model.getStreamBufferUnit().getIndex());
    memoryUnitSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            model.setStreamBufferUnit(MemoryUnit.fromIndex(pos));
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // do nothing
        }
    });

    saveStreamCheckBox = (CheckBox) rootView.findViewById(R.id.saveStreamDataCheckbox);
    saveStreamCheckBox.setChecked(model.isSaveStreams());
    streamBufferSizeInput.setEnabled(saveStreamCheckBox.isChecked());
    memoryUnitSpinner.setEnabled(saveStreamCheckBox.isChecked());
    streamQueueSize = (EditText) rootView.findViewById(R.id.streamQueueSize);
    streamQueueSize.setText(String.valueOf(model.getStreamQueueSize()));
    streamQueueSize.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            String val = s.toString();
            if (!val.isEmpty() && StringUtils.isNumeric(val)) {
                model.setStreamQueueSize(Integer.valueOf(s.toString()));
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    streamQueueSize.setEnabled(model.isSaveStreams() && !model.isAutoStreamQueueSize());
    radioQueueGroup = (RadioGroup) rootView.findViewById(R.id.queueRadioGroup);
    autoStreamQueueSizeRadio = (RadioButton) rootView.findViewById(R.id.autoBufferRadio);
    manualStreamQueueSizeRadio = (RadioButton) rootView.findViewById(R.id.manualBufferRadio);
    if (model.isAutoStreamQueueSize()) {
        autoStreamQueueSizeRadio.setChecked(true);
    } else {
        manualStreamQueueSizeRadio.setChecked(true);
    }
    autoStreamQueueSizeRadio.setEnabled(model.isSaveStreams());
    manualStreamQueueSizeRadio.setEnabled(model.isSaveStreams());
    radioQueueGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
            case R.id.autoBufferRadio:
                model.setAutoStreamQueueSize(true);
                streamQueueSize.setEnabled(false);
                break;
            case R.id.manualBufferRadio:
                model.setAutoStreamQueueSize(false);
                streamQueueSize.setEnabled(true);
                break;
            }
        }
    });

    saveStreamCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setSaveStreams(isChecked);
            externalStorageRadio.setEnabled(model.isSaveStreams() || model.isSaveLogs());
            internalStorageRadio.setEnabled(model.isSaveStreams() || model.isSaveLogs());
            streamBufferSizeInput.setEnabled(isChecked);
            memoryUnitSpinner.setEnabled(isChecked);
            autoStreamQueueSizeRadio.setEnabled(model.isSaveStreams());
            manualStreamQueueSizeRadio.setEnabled(model.isSaveStreams());
            streamQueueSize.setEnabled(model.isSaveStreams() && !model.isAutoStreamQueueSize());
        }
    });

    simulateEditText = (EditText) rootView.findViewById(R.id.simulateComputationsEditText);
    simulateEditText.setText(String.valueOf(model.getSimulateComputations()));
    simulateEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            model.setSimulateComputations(Short.valueOf(s.toString()));
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    normalPriorityCheckBox = (CheckBox) rootView.findViewById(R.id.normalPriorityCheckbox);
    normalPriorityCheckBox.setChecked(model.isNormalThreadPriority());
    normalPriorityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setNormalThreadPriority(isChecked);
        }
    });

    hiPriorityAndroidCheckBox = (CheckBox) rootView.findViewById(R.id.hiAndroidPriorityCheckbox);
    hiPriorityAndroidCheckBox.setChecked(model.isHiAndroidThreadPriority());
    hiPriorityAndroidCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setHiAndroidThreadPriority(isChecked);
        }
    });

    hiPriorityJavaCheckBox = (CheckBox) rootView.findViewById(R.id.hiJavaPriorityCheckbox);
    hiPriorityJavaCheckBox.setChecked(model.isHiJavaThreadPriority());
    hiPriorityJavaCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setHiJavaThreadPriority(isChecked);
        }
    });

    extendedDevicesCombination = (CheckBox) rootView.findViewById(R.id.extendedDevicesCheckBox);
    extendedDevicesCombination.setChecked(model.isExtendedDevicesCombination());
    extendedDevicesCombination.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setExtendedDevicesCombination(isChecked);
        }
    });

    fastHub = (CheckBox) rootView.findViewById(R.id.fastHubCheckBox);
    fastHub.setChecked(model.isFastHub());
    fastHub.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setFastHub(isChecked);
        }
    });

    autoEnableGraphCheckBox = (CheckBox) rootView.findViewById(R.id.autoEnableGraphCheckBox);
    autoEnableGraphCheckBox.setChecked(model.isAutoEnableGraph());
    autoEnableGraphCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setAutoEnableGraph(isChecked);
        }
    });

    createSequenceChooser(rootView);
    createDeviceChooser(rootView, runButton);
    updateStatus(rootView);
    return rootView;
}

From source file:com.microsoft.windowsazure.mobileservices.zumoe2etestapp.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        startActivity(new Intent(this, ZumoPreferenceActivity.class));
        return true;

    case R.id.menu_run_tests:
        if (getMobileServiceKey().trim() == "" || getMobileServiceURL().trim() == "") {
            startActivity(new Intent(this, ZumoPreferenceActivity.class));
        } else {/*  w w w .j ava2  s . c o  m*/
            runTests();
        }
        return true;

    case R.id.menu_check_all:
        changeCheckAllTests(true);
        return true;

    case R.id.menu_uncheck_all:
        changeCheckAllTests(false);
        return true;

    case R.id.menu_reset:
        refreshTestGroupsAndLog();
        return true;

    case R.id.menu_view_log:
        AlertDialog.Builder logDialogBuilder = new AlertDialog.Builder(this);
        logDialogBuilder.setTitle("Log");

        final WebView webView = new WebView(this);

        String logContent = TextUtils.htmlEncode(mLog.toString()).replace("\n", "<br />");
        String logHtml = "<html><body><pre>" + logContent + "</pre></body></html>";
        webView.loadData(logHtml, "text/html", "utf-8");

        logDialogBuilder.setPositiveButton("Copy", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                clipboardManager.setText(mLog.toString());
            }
        });

        logDialogBuilder.setView(webView);

        logDialogBuilder.create().show();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.app.sniffy.MainActivity.java

public void showTerms() {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View dialoglayout = inflater.inflate(R.layout.terms, null);

    WebView webView = (WebView) dialoglayout.findViewById(R.id.termsView);
    webView.loadUrl("file:///android_asset/license.html");

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Terms & Conditions");
    builder.setView(dialoglayout).setCancelable(false).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    CheckBox checkBox = (CheckBox) dialoglayout.findViewById(R.id.checkBox);
                    if (checkBox.isChecked()) {

                        SharedPreferences.Editor editor = settings.edit();
                        editor.putBoolean("userconsent", true);
                        editor.commit();
                        try {
                            new GetKey(context).execute(
                                    new URI(Utils.getConfigProperty(getResources(), "generate-key") + mDeviceId
                                            + Utils.getConfigProperty(getResources(), "securekey")));
                        } catch (URISyntaxException e1) {
                            Log.d("main activity key generate", e1.toString());
                        }//from  w  w  w . j  a va2 s  .c  o m
                    } else {
                        showTerms();
                    }

                }
            });

    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.entertailion.android.dial.ServerFinder.java

private AlertDialog buildNoWifiDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setMessage(R.string.finder_wifi_not_available);
    builder.setCancelable(false);//from   w w w .  j a  v a 2  s .  co m
    builder.setPositiveButton(R.string.finder_configure, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int id) {
            Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
            startActivityForResult(intent, CODE_WIFI_SETTINGS);
        }
    });
    builder.setNegativeButton(R.string.finder_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int id) {
            setResult(RESULT_CANCELED, null);
            finish();
        }
    });
    return builder.create();
}