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:eu.codeplumbers.cosi.wizards.firstrun.ConnectFragment.java

private void showGiveDevicePasswordDialog() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("Register your device");
    alertDialog.setMessage("Your device is already registered\n Please type your device token");

    final EditText input = new EditText(getActivity());

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    input.setLayoutParams(lp);/* w  w w.j  a va  2 s.  c o m*/
    alertDialog.setView(input);

    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String password = input.getText().toString();

            if (!password.isEmpty()) {
                final JSONObject permissionJson = new JSONObject();
                final JSONObject desc = new JSONObject();
                try {
                    Device device = new Device();
                    device.setUrl(mUrl.getText().toString());
                    device.setLogin(mDeviceName.getText().toString());
                    device.setPassword(password);

                    desc.put("description", "sync all my cozy data");
                    permissionJson.put("All", desc);

                    device.setPermissions(permissionJson.toString());
                    device.setFirstSyncDone(false);
                    device.setSyncCalls(false);
                    device.setSyncContacts(false);
                    device.setSyncFiles(false);
                    device.setSyncNotes(false);

                    device.save();

                    onRegisterSuccess(device);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                input.setError("Your device token can not be empty!");
            }
        }
    });
    alertDialog.show();
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * Opens a url in an alert dialog.//from w w  w.  j  av a  2 s  .  c  o m
 * 
 * @param context
 * @param title
 * @param url
 */
public static void dialog_showUrlInDialog(Context context, String title, String url) {
    AlertDialog.Builder alert = new AlertDialog.Builder(context);
    alert.setTitle(title);
    WebView wv = new WebView(context);
    wv.loadUrl(url);
    wv.setHorizontalScrollBarEnabled(false);
    alert.setView(wv);
    alert.setNegativeButton("Close", null);
    alert.show();
}

From source file:br.com.GUI.perfil.MeusAlunos.java

public void atualizarInterface() {
    listDataHeader = new ArrayList<RowItemAluno>();

    if (alunos.isEmpty()) {
        Log.i("alunos", "esta vazio");
    } else {//from w w  w.  j  a  va2 s.  c  om
        Log.i("aluno", "nao esta vazio");
    }

    List<RowItemExpandedAluno> opcoes = prepararOpcoes();

    for (Aluno a : alunos) {

        byte[] foto = new Aluno().buscarFotoAluno(b, a.getUsuario());
        Bitmap bmp = BitmapFactory.decodeByteArray(foto, 0, foto.length);

        RowItemAluno item = new RowItemAluno();
        item.setImagemPerfil(bmp);
        item.setNomePerfil(a.getNome());
        item.setUsuarioAluno(a.getUsuario());

        listDataHeader.add(item);

    }

    for (RowItemAluno row : listDataHeader) {
        listDataChild.put(row, opcoes);
    }
    /*CustomAdapterAluno adapter = 
    new CustomAdapterAluno(getActivity(),alunosPerfil);
    meusAlunos.setAdapter(adapter);
            
    meusAlunos.setOnItemClickListener(new OnItemClickListener() {
               
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
               
       String usuario = alunos.get(arg2).getUsuario();         
       Intent intent = new Intent(getActivity(),AdicionarAluno.class);
       intent.putExtra("usuario", usuario);
        startActivity(intent);
            
       }
    });*/

    listAdapter = new CustomAdapterExpandedAluno(getActivity(), listDataHeader, listDataChild);

    expListView.setAdapter(listAdapter);

    expListView.setOnChildClickListener(new OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v, final int groupPosition,
                int childPosition, long id) {
            Intent i;
            switch (childPosition) {
            case 0:
                i = new Intent(getActivity(), GerenciarAcompanhamento.class);
                i.putExtra("alunoAcompanhamento", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 1:
                i = new Intent(getActivity(), NovaAvaliacao.class);
                i.putExtra("alunoAvaliacao", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 2:
                i = new Intent(getActivity(), PreescreverTreinamento.class);
                i.putExtra("usuario", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 3:
                i = new Intent(getActivity(), MarcarAula.class);
                i.putExtra("usuario", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 4:

                AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
                alertDialog.setTitle("Ateno");
                alertDialog.setMessage("Voc tem certeza que deseja remover este aluno?");
                alertDialog.setIcon(R.drawable.critical);
                alertDialog.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        Aluno a = new Aluno().buscarAlunoEspecifico(b,
                                listDataHeader.get(groupPosition).getUsuarioAluno());
                        if (a.removerAlunoWeb(a.getUsuario()) && a.removerAluno(b)) {
                            Toast.makeText(getActivity(), "Removido com Sucesso", Toast.LENGTH_SHORT).show();
                            // Exclui todas as aulas marcadas com o personal
                            ArrayList<Aula> aulasParaExcluir = new ArrayList<Aula>();

                            aulasParaExcluir = new Aula().buscarAulasPorPersonalWeb(a.getUsuarioPersonal(), "");
                            for (Aula c : aulasParaExcluir) {
                                if (c.excluirAulaWeb() && c.excluirAula(b)) {
                                    Log.i("INFORMAO", "Aulas excluidas com sucesso!");
                                }
                            }
                        } else {
                            Toast.makeText(getActivity(), "Falha ao Remover o aluno", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    }
                });
                alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });

                alertDialog.show();

                break;
            }

            atualizarInterface();

            return false;
        }

    });
}

From source file:com.aslanoba.hwc.SettingsActivity.java

/**
 * Called to handle back key to prompt user to save any pending settings in UI
 *//*from ww  w  .jav  a2  s .c o m*/
protected void handleUIPendingSettings() {
    //need to prompt user
    AlertDialog.Builder dlgWarning = new AlertDialog.Builder(this);
    dlgWarning.setTitle(R.string.UnsavedChangesWarningTitle);

    ClientConfig oConfig = new ClientConfig();
    if (oConfig.isInitialized())
        dlgWarning.setMessage(R.string.SaveConnectionChangeWarningText);
    else
        dlgWarning.setMessage(R.string.UnsavedChangesWarningMessage);

    dlgWarning.setPositiveButton(R.string.UnsavedChangesSaveButton, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            Log.v("ALPER", "handleUIPendingSettings");
            save();
            SettingsActivity.this.finish();
        }
    });
    dlgWarning.setNeutralButton(R.string.UnsavedChangesDiscardButton, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            SettingsActivity.this.finish();
        }
    });

    dlgWarning.show();
}

From source file:com.speed.traquer.app.TraqComplaintTaxi.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        final AlertDialog.Builder alertBox = new AlertDialog.Builder(TraqComplaintTaxi.this);
        alertBox.setIcon(R.drawable.info_icon);
        alertBox.setCancelable(false);//from w  w  w .j a va 2 s. c o m
        alertBox.setTitle("Do you want to cancel complaint?");
        alertBox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                // finish used for destroyed activity
                easyTracker.send(MapBuilder
                        .createEvent("Complaint", "Cancel Complaint (Yes)", "Complaint event", null).build());
                NavUtils.navigateUpFromSameTask(TraqComplaintTaxi.this);
            }
        });

        alertBox.setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int arg1) {
                easyTracker.send(MapBuilder
                        .createEvent("Complaint", "Cancel Complaint (No)", "Complaint event", null).build());
                dialog.cancel();
            }
        });

        alertBox.show();
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.ifeel.healthy.SelectionFragment.java

private void openHtml(String htmlFile, String title) {
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setTitle(title);//from   ww  w .ja va 2  s  .c  o m

    WebView wv = new WebView(getActivity());

    // loading the html file
    String htmlData = readAsset(htmlFile);

    //wv.loadUrl("http://ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=ifeelmobiltec-20&marketplace=amazon&region=US&placement=B007S088F4&asins=B007S088F4&linkId=JCQFMHWLLV5N2SZO&show_border=true&link_opens_in_new_window=true");
    wv.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "UTF-8", null);

    alert.setView(wv);
    alert.setNegativeButton(getActivity().getString(R.string.close), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

    alert.create();
    alert.show();
}

From source file:cn.count.easydrive366.signup.Step3Activity.java

private void chooseDriverType() {
    final JSONArray list = AppSettings.driver_type_list;
    if (list == null) {
        return;/*from ww w . j  a v a2 s  .c om*/
    }
    String types = edtCar_type.getText().toString();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    MultiChoiceID.clear();
    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle(this.getResources().getString(R.string.app_name));

    final String[] items = new String[list.length()];
    boolean[] checkedItems = new boolean[list.length()];
    try {
        for (int i = 0; i < list.length(); i++) {
            JSONObject item = list.getJSONObject(i);
            String code = item.getString("code");
            String name = item.getString("name");
            String years = item.getString("years");
            items[i] = String.format("%s--%s(%s)", code, name, years);
            if (types.contains(code)) {
                checkedItems[i] = true;
                MultiChoiceID.add(i);
            } else {
                checkedItems[i] = false;
            }
        }
    } catch (Exception e) {
        log(e);
    }

    builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                if (!MultiChoiceID.contains(which))
                    MultiChoiceID.add(which);
            } else {
                if (MultiChoiceID.contains(which)) {
                    int i_index = MultiChoiceID.indexOf(which);
                    MultiChoiceID.remove(i_index);
                }
            }

        }
    });
    builder.setPositiveButton(this.getResources().getString(R.string.ok),
            new DialogInterface.OnClickListener() {

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

                    changeDriverType();
                }
            });
    builder.setNegativeButton(this.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                }
            });
    builder.show();
}

From source file:dentex.youtube.downloader.DashboardActivity.java

public void secureShowDialog(AlertDialog.Builder adb) {
    //builder.create();
    if (!((Activity) DashboardActivity.this).isFinishing()) {
        adb.show();
    }// w  w w  .j  a  v a  2  s.  co m
}

From source file:ac.robinson.bettertogether.ConnectionSetupActivity.java

private boolean checkSettingsAccess() {
    // TODO: by default, applications are not granted access, but the settings switch shows access is allowed - need to
    // TODO: toggle this switch to actually grant access. Need to improve this interaction generally
    if (!canWriteSettings()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(ConnectionSetupActivity.this);
        builder.setTitle(R.string.title_settings_access);
        builder.setMessage(R.string.hint_enable_settings_access);
        builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override/*from ww  w.  ja v  a 2  s. co  m*/
            public void onDismiss(DialogInterface dialog) {
                // note: dismiss rather than cancel so we always take this action (pos or neg result)
                if (checkSettingsAccess()) {
                    if (mConnectionMode == ConnectionMode.CONNECTION_INITIATED_HOTSPOT) {
                        createHotspot();
                        return;
                    }
                }
                mConnectionMode = ConnectionMode.SCANNING;
                setupDefaultUI();
            }
        });
        builder.setPositiveButton(R.string.hint_edit_settings_access, new DialogInterface.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.M)
            @Override
            public void onClick(DialogInterface dialog, int which) {
                try {
                    Intent settingsIntent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
                    settingsIntent.setData(Uri.parse("package:" + PluginIntent.HOST_PACKAGE));
                    startActivity(settingsIntent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(ConnectionSetupActivity.this, R.string.error_editing_settings,
                            Toast.LENGTH_LONG).show();
                    // TODO: reset ui?
                }
                dialog.dismiss();
            }
        });
        builder.setNeutralButton(R.string.button_done, null);
        builder.show();
        return false;
    }
    return true;
}