Example usage for android.app AlertDialog.Builder setIcon

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

Introduction

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

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

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

public void tirarFoto() {

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("Selecione o mtodo");
    alertDialog.setMessage("Deseja usar qual aplicativo para importar sua foto?");
    alertDialog.setIcon(R.drawable.profile);
    alertDialog.setPositiveButton("Camera", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            usarCamera();/*from   w  w  w.j  av  a  2s  . co  m*/
        }
    });
    alertDialog.setNegativeButton("Galeria", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            usarGaleria();
            dialog.cancel();
        }
    });

    alertDialog.show();

}

From source file:jackpal.androidterm.TermPreferences.java

@Override
protected void onActivityResult(int request, int result, Intent data) {
    super.onActivityResult(request, result, data);
    switch (request) {
    case REQUEST_PREFS_READ_PICKER:
        if (result == RESULT_OK && data != null) {
            Uri uri = data.getData();/*  w  w  w.  j a v  a2 s .c  om*/
            if (readPrefs(uri, false))
                onCreate(null);
            break;
        }
        break;
    case REQUEST_FONT_PICKER:
        String path;
        if (result == RESULT_OK && data != null) {
            Uri uri = data.getData();
            path = getPath(this, uri);
            if (path != null && path.matches(".*\\.(?i)(ttf|ttc|otf)")) {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
                sp.edit().putString(FONT_FILENAME, path).apply();
            } else {
                AlertDialog.Builder bld = new AlertDialog.Builder(this);
                bld.setIcon(android.R.drawable.ic_dialog_alert);
                bld.setMessage(this.getString(R.string.font_file_error));
                bld.setPositiveButton(this.getString(android.R.string.ok), null);
                bld.create().show();
                break;
            }
        }
        break;
    default:
        break;
    }
}

From source file:jackpal.androidterm.TermPreferences.java

@Override
@SuppressLint("NewApi")
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    switch (requestCode) {
    case REQUEST_STORAGE_FONT_PICKER:
    case REQUEST_STORAGE_PREFS_PICKER:
        for (int i = 0; i < permissions.length; i++) {
            if (permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                    switch (requestCode) {
                    case REQUEST_STORAGE_FONT_PICKER:
                        doFilePicker();//from ww  w .  j  av  a 2s . c o  m
                        break;
                    case REQUEST_STORAGE_PREFS_PICKER:
                        doPrefsPicker();
                        break;
                    default:
                        break;
                    }
                } else {
                    AlertDialog.Builder bld = new AlertDialog.Builder(this);
                    bld.setIcon(android.R.drawable.ic_dialog_alert);
                    bld.setMessage(this.getString(R.string.storage_permission_error));
                    bld.setPositiveButton(this.getString(android.R.string.ok), null);
                    bld.create().show();
                }
            }
        }
        break;
    default:
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        break;
    }
}

From source file:qauth.djd.qauthclient.main.ContentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle args = getArguments();//from   w w  w .  j  a v a2 s. com
    if (args.getCharSequence(KEY_TITLE).toString().equals("Providers")) {

        View rootView = inflater.inflate(R.layout.providers_view_frag, container, false);

        mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
        mLayoutManager = new LinearLayoutManager(getActivity());
        mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

        if (savedInstanceState != null) {
            // Restore saved layout manager type.
            mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState
                    .getSerializable(KEY_LAYOUT_MANAGER);
        }
        setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

        pAdapter = new ProviderAdapter(pDataset);
        mRecyclerView.setAdapter(pAdapter);

        final PackageManager pm = getActivity().getPackageManager();
        List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

        for (ApplicationInfo packageInfo : packages) {
            //Log.i(TAG, "Installed package :" + packageInfo.packageName);
            //Log.i(TAG, "Source dir : " + packageInfo.sourceDir);
            //Log.i(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName));

            if (packageInfo.packageName.equals("qauth.djd.dummyclient")) {
                Provider provider = new Provider("DummyClient", packageInfo.packageName);
                pDataset.add(provider);
                pAdapter.notifyDataSetChanged();
            }

        }

        //get local package names and cross reference with providers on server ("/provider/available")
        //display package names in listview
        //allow user to click on item to activate or deactivate
        // '-> have check box with progress bar indicating status

        return rootView;

    } else {

        View rootView = inflater.inflate(R.layout.recycler_view_frag, container, false);
        mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
        mLayoutManager = new LinearLayoutManager(getActivity());
        mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

        if (savedInstanceState != null) {
            // Restore saved layout manager type.
            mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState
                    .getSerializable(KEY_LAYOUT_MANAGER);
        }
        setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

        wAdapter = new WatchAdapter(wDataset);
        mRecyclerView.setAdapter(wAdapter);

        FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
        fab.attachToRecyclerView(mRecyclerView);

        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("test", "clicked!");

                AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity());
                builderSingle.setIcon(R.drawable.ic_launcher);
                builderSingle.setTitle("Select Bluetooth Device");
                final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(),
                        android.R.layout.select_dialog_singlechoice);
                new Thread(new Runnable() {
                    public void run() {
                        for (String s : getNodes()) {
                            arrayAdapter.add(s);
                        }
                    }
                }).start();
                builderSingle.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        String nodeId = arrayAdapter.getItem(which);
                        String privKey = null;
                        String pubKey = null;

                        try {
                            SecureRandom random = new SecureRandom();
                            RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(1024,
                                    RSAKeyGenParameterSpec.F4);
                            KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "SC");
                            generator.initialize(spec, random);
                            KeyPair pair = generator.generateKeyPair();
                            privKey = Base64.encodeToString(pair.getPrivate().getEncoded(), Base64.DEFAULT);
                            pubKey = Base64.encodeToString(pair.getPublic().getEncoded(), Base64.DEFAULT);
                        } catch (Exception e) {
                            Log.i("generate", "error: " + e);
                        }

                        //Log.i("keys", "priv key : " + privKey);

                        //String privKey = Base64.encodeToString(MainTabsActivity.privKey.getEncoded(), Base64.DEFAULT);
                        //String pubKey = Base64.encodeToString(MainTabsActivity.pubKey.getEncoded(), Base64.DEFAULT);

                        Keys keys = new Keys(privKey, pubKey);
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        ObjectOutput out = null;
                        try {
                            out = new ObjectOutputStream(bos);
                        } catch (Exception e) {
                        }
                        try {
                            out.writeObject(keys);
                        } catch (Exception e) {
                        }
                        byte b[] = bos.toByteArray();
                        try {
                            out.close();
                        } catch (Exception e) {
                        }
                        try {
                            bos.close();
                        } catch (Exception e) {
                        }

                        Wearable.MessageApi.sendMessage(mGoogleApiClient, nodeId, "REGISTER", b)
                                .setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
                                    @Override
                                    public void onResult(MessageApi.SendMessageResult sendMessageResult) {
                                        if (!sendMessageResult.getStatus().isSuccess()) {
                                            Log.i("MessageApi", "Failed to send message with status code: "
                                                    + sendMessageResult.getStatus().getStatusCode());
                                        } else if (sendMessageResult.getStatus().isSuccess()) {
                                            Log.i("MessageApi", "onResult successful!");
                                        }
                                    }
                                });

                    }
                });
                builderSingle.show();

            }
        });

        mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(
                        new com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener() {
                            @Override
                            public void onConnectionFailed(ConnectionResult result) {
                                Log.i("mGoogleApiClient", "onConnectionFailed: " + result);
                            }
                        })
                // Request access only to the Wearable API
                .addApi(Wearable.API).build();
        mGoogleApiClient.connect();

        /*BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
                
        for(BluetoothDevice bt : pairedDevices)
        Log.i("BluetoothDevice", "pairedDevice: " + bt.toString());*/

        return rootView;

    }

}

From source file:de.k3b.android.toGoZip.SettingsActivity.java

/**
 * return false if no error. else Show Dialog cancel/setToDefault/Edit
 *//*  ww w. ja  v a  2s .c  om*/
private void showNeedPermissionDialog() {
    String currentZipPath = SettingsImpl.getAbsoluteZipFile().getAbsolutePath();
    String defaultZipPath = SettingsImpl.getDefaultZipDirPath(this);
    boolean canWriteDefault = SettingsImpl.canWrite(this, defaultZipPath);

    String format = (canWriteDefault) ? getString(R.string.ERR_NO_WRITE_PERMISSIONS_CHANGE_TO_DEFAULT)
            : getString(R.string.ERR_NO_WRITE_PERMISSIONS);

    if (defaultZipPath.compareTo(currentZipPath) == 0) {
        currentZipPath = ""; // display name only once
    }
    String msg = String.format(format, currentZipPath, defaultZipPath);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(msg);
    builder.setTitle(R.string.title_activity_add2zip);
    builder.setIcon(R.drawable.ic_launcher);
    //builder.setPositiveButton(R.string.delete, this);
    //builder.setNegativeButton(R.string.cancel, this);

    builder.setNegativeButton(R.string.cmd_cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            cancel();
        }
    });
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            cancel();
        }
    });

    builder.setPositiveButton(R.string.cmd_edit, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            checkRuntimePermission();
        }
    });

    builder.show();
}

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

public void atualizarDadosPersonal() {

    if (nome.getText().toString() == null) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
        alertDialog.setTitle("Ateno");
        alertDialog.setMessage("Por favor, digite o seu nome");
        alertDialog.setIcon(R.drawable.critical);
        alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();/*w  w  w. j av a 2s . com*/
            }
        });

        alertDialog.show();
    } else {

        byte[] byteFoto = ImageUtils.bitmapToByteArray(bmp);
        String fotoPersonal = Base64.encodeToString(byteFoto, 0);

        String dataDeNascimento = dataNascimentoDia.getValue() + "/" + dataNascimentoMes.getValue() + "/"
                + dataNascimentoAno.getValue();

        final Personal p = new Personal(telefone.getText().toString(), nome.getText().toString(),
                dataDeNascimento, email.getText().toString(), pref.getString("sexo", null),
                pref.getString("usuario", null), pref.getString("senha", null), fotoPersonal);

        boolean r = p.atualizarPersonalWeb();

        if (r && p.atualizar(b, byteFoto)) {
            Toast.makeText(getActivity(), "Atualizado com Sucesso", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getActivity(), "Erro ao salvar no servidor", Toast.LENGTH_SHORT).show();

        }
    }
}

From source file:com.support.android.designlibdemo.activities.CampaignDetailActivity.java

public AlertDialog.Builder buildDialogNoPictures(Context c) {
    AlertDialog.Builder builder = new AlertDialog.Builder(c);
    builder.setTitle("There are no photos yet");
    builder.setMessage("Be first one and add more supportive pictures for this campaign");
    builder.setIcon(R.mipmap.ic_launcher_sou);
    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override/*from w  w w  . j av  a2s.co  m*/
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    return builder;
}

From source file:fr.pasteque.client.Configure.java

/**
 * Display an AlertDialog//ww w  . j  a v a 2  s  .com
 * Based on Error.showError() but Configuration is not a TrackedActivity
 *
 * @param message to display
 */
private void showError(String message) {
    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle(R.string.error_title);
    b.setMessage(message);
    b.setIcon(android.R.drawable.ic_dialog_alert);
    b.setCancelable(true);
    b.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Configure.this.invalidateError();
        }
    });
    b.show();
}

From source file:org.asnelt.derandom.MainActivity.java

/**
 * Opens an about dialog. Called when the user clicks the about item.
 *///  www.j a  v  a2  s  . c  o m
private void openAbout() {
    // Construct an about dialog
    String versionName;
    try {
        versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = "unknown";
    }
    @SuppressLint("InflateParams")
    View inflater = getLayoutInflater().inflate(R.layout.dialog_about, null);

    TextView textVersion = (TextView) inflater.findViewById(R.id.text_version);
    textVersion.setText(String.format("%s %s", textVersion.getText().toString(), versionName));

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle("About " + getResources().getString(R.string.app_name));
    builder.setView(inflater);
    builder.create();
    builder.show();
}

From source file:it.scoppelletti.mobilepower.app.HelpDialogFragment.java

/**
 * Crea il dialogo./*from ww  w . j  a  v  a2s.co m*/
 * 
 * @param  savedInstanceState Stato dell&rsquo;istanza.
 * @return                    Dialogo.
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int mode, resId;
    View contentView;
    AlertDialog dlg;
    AlertDialog.Builder builder;
    LayoutInflater inflater;
    TextView textControl;
    Bundle args = getArguments();

    builder = newAlertDialogBuilder();

    resId = args.getInt(HelpDialogFragment.ARG_TITLEID, 0);
    if (resId > 0) {
        builder.setTitle(resId);
    }

    inflater = getActivity().getLayoutInflater();
    contentView = inflater.inflate(R.layout.helpdialog, null);
    builder.setView(contentView);

    builder.setIcon(android.R.drawable.ic_dialog_info);

    mode = getArguments().getInt(HelpDialogFragment.ARG_MODE, HelpDialogFragment.MODE_HELP);
    switch (mode) {
    case HelpDialogFragment.MODE_CONFIRM:
        setCancelable(false);
        builder.setCancelable(false);
        builder.setPositiveButton(R.string.cmd_proceed, this);
        builder.setNegativeButton(android.R.string.cancel, this);
        break;

    default: // HelpDialogFragment.MODE_HELP
        builder.setNeutralButton(R.string.cmd_close, null);
        break;
    }

    dlg = builder.create();

    textControl = (TextView) contentView.findViewById(R.id.txt_help);
    textControl.setKeyListener(null);

    resId = args.getInt(HelpDialogFragment.ARG_TEXTID, 0);
    if (resId > 0) {
        textControl.setText(Html.fromHtml(getResources().getString(resId)));
    }

    return dlg;
}