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:com.nest5.businessClient.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *//*from  w ww  .jav a 2 s . co  m*/
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Set "connecting" status
                SharedPreferences prefs = Util.getSharedPreferences(mContext);
                prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit();
                // Get account name
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                // Register
                register((String) account.getText());
                finish();
            }
        });
    }

    // internetConnectionStatus = (ImageView) findViewById(R.id.header_connection_status);
    SharedPreferences prefs = Util.getSharedPreferences(mContext);
    if (!isNetworkAvailable()) {
        internetConnectionStatus.setImageResource(R.drawable.error);

        prefs.edit().putInt(Util.INTERNET_CONNECTION, Util.INTERNET_DISCONNECTED).commit();
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(
                "No tienes una conexin a internet activa. Habiltala haciendo click en aceptar y seleccionando luego una red.")
                .setCancelable(false).setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
                        startActivityForResult(intent, 1);
                    }
                }).setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        finish();
                    }
                }).show();

    } else {
        prefs.edit().putInt(Util.INTERNET_CONNECTION, Util.INTERNET_CONNECTED).commit();
    }
}

From source file:com.owncloud.android.ui.activity.ReceiveExternalFilesActivity.java

@Override
protected Dialog onCreateDialog(final int id) {
    final AlertDialog.Builder builder = new Builder(this);
    switch (id) {
    case DIALOG_NO_ACCOUNT:
        builder.setIcon(R.drawable.ic_warning);
        builder.setTitle(R.string.uploader_wrn_no_account_title);
        builder.setMessage(/*from w  ww  .j  a v a2  s  . co  m*/
                String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name)));
        builder.setCancelable(false);
        builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) {
                    // using string value since in API7 this
                    // constatn is not defined
                    // in API7 < this constatant is defined in
                    // Settings.ADD_ACCOUNT_SETTINGS
                    // and Settings.EXTRA_AUTHORITIES
                    Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
                    intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() });
                    startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
                } else {
                    // since in API7 there is no direct call for
                    // account setup, so we need to
                    // show our own AccountSetupAcricity, get
                    // desired results and setup
                    // everything for ourself
                    Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class);
                    startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
                }
            }
        });
        builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        return builder.create();
    case DIALOG_MULTIPLE_ACCOUNT:
        Account accounts[] = mAccountManager.getAccountsByType(MainApp.getAccountType());
        CharSequence dialogItems[] = new CharSequence[accounts.length];
        OwnCloudAccount oca;
        for (int i = 0; i < dialogItems.length; ++i) {
            try {
                oca = new OwnCloudAccount(accounts[i], this);
                dialogItems[i] = oca.getDisplayName() + " @ " + DisplayUtils
                        .convertIdn(accounts[i].name.substring(accounts[i].name.lastIndexOf("@") + 1), false);

            } catch (Exception e) {
                Log_OC.w(TAG, "Couldn't read display name of account; using account name instead");
                dialogItems[i] = DisplayUtils.convertIdn(accounts[i].name, false);
            }
        }
        builder.setTitle(R.string.common_choose_account);
        builder.setItems(dialogItems, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]);
                onAccountSet(mAccountWasRestored);
                dialog.dismiss();
                mAccountSelected = true;
                mAccountSelectionShowing = false;
            }
        });
        builder.setCancelable(true);
        builder.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                mAccountSelectionShowing = false;
                dialog.cancel();
                finish();
            }
        });
        return builder.create();
    default:
        throw new IllegalArgumentException("Unknown dialog id: " + id);
    }
}

From source file:de.frank_durr.ble_v_monitor.MainActivity.java

private void showAboutDialog() {
    View view = getLayoutInflater().inflate(R.layout.dialog_about, null, false);
    TextView textView = (TextView) view.findViewById(R.id.about_message);
    textView.setText(Html.fromHtml(getString(R.string.about_message)));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.mipmap.ic_launcher);
    builder.setTitle(R.string.app_name);
    builder.setView(view);//from   w w  w .  j a va  2 s. co  m
    builder.create();
    builder.show();
}

From source file:org.akvo.caddisfly.ui.activity.MainActivity.java

@Override
public void onLoadCalibration(final Handler.Callback callback) {
    final Context context = this;
    final MainApp mainApp = (MainApp) this.getApplicationContext();

    try {/* www.  java 2 s . co m*/
        AlertDialog.Builder builderSingle = new AlertDialog.Builder(context);
        builderSingle.setIcon(R.drawable.ic_launcher);
        builderSingle.setTitle(R.string.loadCalibration);

        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context,
                android.R.layout.select_dialog_singlechoice);

        File external = Environment.getExternalStorageDirectory();
        final String folderName = Config.CALIBRATE_FOLDER_NAME;
        String path = external.getPath() + folderName;
        File folder = new File(path);
        if (folder.exists()) {
            final File[] listFiles = folder.listFiles();
            for (File listFile : listFiles) {
                arrayAdapter.add(listFile.getName());
            }

            builderSingle.setNegativeButton(R.string.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 fileName = listFiles[which].getName();
                    final ArrayList<Integer> swatchList = new ArrayList<Integer>();

                    final ArrayList<String> rgbList = FileUtils.loadFromFile(fileName);
                    if (rgbList != null) {

                        for (String rgb : rgbList) {
                            swatchList.add(ColorUtils.getColorFromRgb(rgb));
                        }
                        (new AsyncTask<Void, Void, Void>() {
                            @Override
                            protected Void doInBackground(Void... params) {
                                mainApp.saveCalibratedSwatches(mainApp.currentTestInfo.getCode(), swatchList);

                                mainApp.setSwatches(mainApp.currentTestInfo.getCode());

                                SharedPreferences sharedPreferences = PreferenceManager
                                        .getDefaultSharedPreferences(context);
                                SharedPreferences.Editor editor = sharedPreferences.edit();

                                for (int i = 0; i < mainApp.rangeIntervals.size(); i++) {
                                    int index = i * mainApp.rangeIncrementStep;

                                    ColorUtils.autoGenerateColors(index, mainApp.currentTestInfo.getCode(),
                                            mainApp.colorList, mainApp.rangeIncrementStep, editor, 0);
                                }
                                editor.apply();
                                return null;
                            }

                            @Override
                            protected void onPostExecute(Void result) {
                                super.onPostExecute(result);
                                callback.handleMessage(null);
                            }
                        }).execute();

                    }
                }
            });

            final AlertDialog alert = builderSingle.create();
            alert.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialogInterface) {
                    final ListView listView = alert.getListView();
                    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
                        @Override
                        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
                            final int position = i;

                            AlertUtils.askQuestion(context, R.string.delete, R.string.selectedWillBeDeleted,
                                    new DialogInterface.OnClickListener() {
                                        @SuppressWarnings("unchecked")
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            String fileName = listFiles[position].getName();
                                            FileUtils.deleteFile(folderName, fileName);
                                            ArrayAdapter listAdapter = (ArrayAdapter) listView.getAdapter();
                                            listAdapter.remove(listAdapter.getItem(position));
                                        }
                                    });
                            return true;
                        }
                    });

                }
            });
            alert.show();
        } else {
            AlertUtils.showMessage(context, R.string.notFound, R.string.noSavedCalibrations);
        }
    } catch (ActivityNotFoundException e) {
        AlertUtils.showMessage(context, R.string.error, R.string.updateRequired);
    }

    callback.handleMessage(null);
}

From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.UpdateMetadataDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    rootView = inflater.inflate(R.layout.dialog_update_metadata, null);

    versionVisible = false;//from w  ww . j av a2s . c  om

    Bundle bundle = getArguments();

    position = bundle.getInt("position");
    hash_algorithm = bundle.getString("hash_algorithm");
    bindToDevice_enabled = bundle.getBoolean("bindToDevice_enabled");

    database = MetaDataSQLiteHelper.getInstance(getActivity());
    metaData = database.getMetaData(position);
    oldMetaData = database.getMetaData(position);
    number_iterations = bundle.getInt("number_iterations");

    builder.setView(rootView);
    setUpData();

    builder.setIcon(R.mipmap.ic_drawer);

    builder.setTitle(getActivity().getString(R.string.add_new_metadata_heading));

    builder.setPositiveButton(getActivity().getString(R.string.save), new DialogInterface.OnClickListener() {

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

            updateMetadata(oldMetaData.getITERATION());

        }
    });

    builder.setNegativeButton(getActivity().getString(R.string.cancel), new DialogInterface.OnClickListener() {

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

            cancelUpdate();

        }
    });

    Button versionButton = (Button) rootView.findViewById(R.id.versionButton);
    versionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            RelativeLayout versionDataLayout = (RelativeLayout) rootView.findViewById(R.id.updateVersionLayout);
            TextView versionTextView = (TextView) rootView.findViewById(R.id.versionButton);
            TextView textViewIteration = (TextView) rootView.findViewById(R.id.textViewIteration);
            if (!versionVisible) {
                versionDataLayout.setVisibility(View.VISIBLE);
                textViewIteration.setVisibility(View.VISIBLE);
                versionTextView.setText(getString(R.string.change_version_opened));
                versionTextView.setTextColor(Color.BLACK);
                versionVisible = true;
            } else {
                versionDataLayout.setVisibility(View.GONE);
                textViewIteration.setVisibility(View.GONE);
                versionTextView.setText(getString(R.string.change_version_closed));
                versionTextView.setTextColor(Color.parseColor("#d3d3d3"));
                versionVisible = false;
            }

        }

    });

    ImageButton versionInfoImageButton = (ImageButton) rootView.findViewById(R.id.versionInfoImageButton);
    versionInfoImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder infoBbuilder = new AlertDialog.Builder(getActivity());
            infoBbuilder.setTitle(getString(R.string.dialog_version_title));
            infoBbuilder.setMessage(R.string.dialog_version);
            infoBbuilder.show();
        }

    });

    return builder.create();
}

From source file:org.wheelmap.android.fragment.ErrorDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    mId = getArguments().getInt(Extra.ID);
    String title;//from   ww  w  .j a  v  a  2s  .  c om
    String msg;
    if (getArguments().containsKey(Extra.ALERT_TITLE)) {
        title = getArguments().getString(Extra.ALERT_TITLE);
        msg = getArguments().getString(Extra.ALERT_MESSAGE);
    } else {
        RestServiceException e = getArguments().getParcelable(Extra.EXCEPTION);
        if (mId == Extra.UNKNOWN) {
            title = getString(R.string.error_network_unknown_failure);
        } else if (e.isNetworkError()) {
            title = getString(R.string.error_network_title);
        } else {
            title = getString(R.string.error_authorization_error);
        }
        msg = title;
    }
    if (title != null) {
        builder.setTitle(title);
    }
    builder.setMessage(msg);
    builder.setIcon(R.drawable.ic_dialog_alert_wheelmap);
    builder.setNeutralButton(R.string.btn_okay, this);
    return builder.create();
}

From source file:com.juick.android.ThreadActivity.java

private void sendReplyMain(String msg) {
    if (tf.listAdapter.getCount() > 0) {
        setFormEnabled(false);/*from  w  w w  .j  a va 2  s  . com*/
        final JuickMessage threadStarter = tf.listAdapter.getItem(0);
        replyInProgress = MainActivity.getMicroBlog(mid.getMicroBlogCode()).postReply(this, mid, threadStarter,
                selectedReply, msg, attachmentUri, attachmentMime, new Utils.Function<Void, String>() {
                    @Override
                    public Void apply(String error) {
                        replyInProgress = null;
                        if (error == null) {
                            Utils.ServiceGetter<DatabaseService> databaseGetter = new Utils.ServiceGetter<DatabaseService>(
                                    ThreadActivity.this, DatabaseService.class);
                            databaseGetter.getService(new Utils.ServiceGetter.Receiver<DatabaseService>() {
                                @Override
                                public void withService(DatabaseService service) {
                                    service.saveRecentlyCommentedThread(threadStarter);
                                }

                            });
                            sendMessageSucceed();
                        } else {
                            setFormEnabled(true);
                            if (attachmentUri != null) {
                                try {
                                    AlertDialog.Builder builder = new AlertDialog.Builder(ThreadActivity.this);
                                    builder.setNeutralButton(R.string.OK, null);
                                    builder.setIcon(android.R.drawable.ic_dialog_alert);
                                    builder.setMessage(error);
                                    builder.show();
                                } catch (Exception e) {
                                    // activity must be dead already
                                }
                            } else {
                                Toast.makeText(ThreadActivity.this, error, Toast.LENGTH_LONG).show();
                            }
                        }
                        return null;
                    }
                });
    } else {
        Toast.makeText(this, "Pardon!", Toast.LENGTH_LONG);
    }
}

From source file:mp.paschalis.EditBookActivity.java

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

    app = (App) getApplication();//from w w w . j  a v a2  s  . c  om

    setContentView(R.layout.activity_edit_book);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Get arguments, to determine who opened this activity
    final Bundle extras = getIntent().getExtras();

    try {
        fromBookSearch = extras.getBoolean(App.ExtrasForEditBookActivityFromBookSearch);
    } catch (Exception e) {
        fromBookSearch = false;
    }

    // Set the layout's data
    // Get layout's Data
    bookISBN = (TextView) findViewById(R.id.textViewBookISBN);

    bookTitle = (TextView) findViewById(R.id.textViewBookTitle);
    bookAuthors = (TextView) findViewById(R.id.textViewBookAuthors);
    bookPublishedYear = (TextView) findViewById(R.id.textViewBookPublishedYear);
    bookPageCount = (TextView) findViewById(R.id.textViewBookPageCount);
    bookDateOfInsert = (TextView) findViewById(R.id.textViewBookDateOfInsert);

    bookCoverImage = (ImageView) findViewById(R.id.imageViewBookCover);

    bookLanguage = (TextView) findViewById(R.id.textViewBookLanguage);

    textViewCheckYourBooks = (TextView) findViewById(R.id.textViewCheckYourBooks);

    TextView tvnocover = (TextView) findViewById(R.id.textViewNoCover);
    ProgressBar pb = (ProgressBar) findViewById(R.id.progressBarLoadCover);

    // show The Image and save it to Library
    ImageLoader.DataClassDisplayBookCover bk = new ImageLoader.DataClassDisplayBookCover();

    bk.iv = bookCoverImage;
    bk.isCover = true;
    bk.pb = pb;
    bk.tv = tvnocover;
    bk.book = app.selectedBook;

    App.imageLoader.DisplayCover(bk);

    // Assign the appropriate data from our alert object above
    bookISBN.setText(app.selectedBook.isbn);
    bookTitle.setText(app.selectedBook.title);
    bookAuthors.setText(app.selectedBook.authors);
    bookPublishedYear.setText(Integer.valueOf(app.selectedBook.publishedYear).toString());
    bookPageCount.setText(Integer.valueOf(app.selectedBook.pageCount).toString());
    bookDateOfInsert
            .setText(App.makeTimeStampHumanReadble(getApplicationContext(), app.selectedBook.dateOfInsert));
    bookLanguage.setText(app.selectedBook.lang);

    progressBarChangeStatusOfBook = (ProgressBar) findViewById(R.id.progressBarChangeBookStatus);
    progressBarLentReturnButton = (ProgressBar) findViewById(R.id.progressBarReturnLentBook);
    progressBarLentDeleteButton = (ProgressBar) findViewById(R.id.progressBarBookDeleteButton);

    buttonDeleteBook = (Button) findViewById(R.id.buttonBookDelete);
    buttonLentReturnBook = (Button) findViewById(R.id.buttonLentReturnBook);

    spinnerEditBookStatus = (Spinner) findViewById(R.id.spinnerBookStatus);

    // Create adapter for the Spinner
    adapter = ArrayAdapter.createFromResource(this, R.array.ArrayBookSetStatus,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner

    spinnerEditBookStatus.setAdapter(adapter);

    getStatusDefaultValue();

    spinnerEditBookStatus.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {

            if (booleanFirstInit) {
                booleanFirstInit = false;
                return;
            }

            // your code here
            new AsyncTaskChangeStatusOfBook().execute(
                    App.getBookStatusCode((String) (adapter.getItem(position)), EditBookActivity.this));
        }

        @Override
        public void onNothingSelected(AdapterView<?> parentView) {
        }

    });

    // Hybrid button: Lent/Return a book
    buttonLentReturnBook.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            {
                // Lent the book
                if (buttonLentReturnBook.getText().toString().equals(getString(R.string.lent))) {
                    // Send ISBN As Argument
                    Intent i = new Intent(getApplicationContext(), LentBookActivity.class);
                    i.putExtra(App.ExtrasForLentBookActivityISBN, bookISBN.getText().toString());
                    EditBookActivity.this.startActivity(i);
                }
                // Return the book
                else {

                    {
                        AlertDialog.Builder alert = new AlertDialog.Builder(EditBookActivity.this);
                        alert.setTitle(R.string.msgIsItReturnedToYou_);

                        alert.setIcon(R.drawable.ic_menu_forward);

                        alert.setNegativeButton(R.string.no,
                                new android.content.DialogInterface.OnClickListener() {

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

                        alert.setPositiveButton(R.string.yes,
                                new android.content.DialogInterface.OnClickListener() {

                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        // Return the book
                                        new AsyncTaskReturnABook().execute(app.selectedBook.isbn);
                                    }
                                });

                        alert.show();

                    }

                }
            }

        }
    });// End of Lent/Return Button!

    // Delete Button
    buttonDeleteBook.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(EditBookActivity.this);
                alert.setTitle(R.string.msgAreYouSureDelBOok_);

                alert.setIcon(R.drawable.ic_dialog_alert_holo_light);

                alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() {

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

                alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Return the book

                        new AsyncTaskDeleteABook().execute(app.selectedBook.isbn);
                    }
                });

                alert.show();

            }

        }
    });

}

From source file:me.piebridge.prevent.ui.PreventActivity.java

private void showDisableDialog(String result) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.app_name) + "(" + BuildConfig.VERSION_NAME + ")");
    if (result == null) {
        builder.setMessage(R.string.xposed_disabled);
    } else {/*from ww  w . jav a 2 s.c  om*/
        builder.setMessage(result);
    }
    builder.setIcon(R.drawable.ic_launcher);
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            finish();
        }
    });
    builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent("de.robv.android.xposed.installer.OPEN_SECTION");
            intent.setPackage("de.robv.android.xposed.installer");
            intent.putExtra("section", "modules");
            intent.putExtra("module", getPackageName());
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) { // NOSONAR
                finish();
            }
        }
    });
    builder.create().show();
}

From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java

private void startNavigation(final Context context) {
    final NavItem[] items = {
            new NavItem("   " + getString(R.string.nav_oepnv), R.drawable.ic_directions_bus_gray_24px),
            new NavItem("   " + getString(R.string.nav_car), R.drawable.ic_directions_car_gray_24px),
            new NavItem("   " + getString(R.string.nav_bike), R.drawable.ic_directions_bike_gray_24px),
            new NavItem("   " + getString(R.string.nav_walk), R.drawable.ic_directions_walk_gray_24px),
            new NavItem("   " + getString(R.string.nav_show), R.drawable.ic_info_gray_24px) };

    ListAdapter adapter = new ArrayAdapter<NavItem>(this, android.R.layout.select_dialog_item,
            android.R.id.text1, items) {
        public View getView(int position, View convertView, ViewGroup parent) {
            //Use super class to create the View
            View v = super.getView(position, convertView, parent);
            TextView tv = (TextView) v.findViewById(android.R.id.text1);

            //Put the image on the TextView
            tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);

            //Add margin between image and text (support various screen densities)
            int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
            int dp7 = (int) (20 * getResources().getDisplayMetrics().density);
            tv.setCompoundDrawablePadding(dp5);
            tv.setPadding(dp7, 0, 0, 0);

            return v;
        }// w w w .ja va2s.  c o m
    };

    AlertDialog.Builder navBuilder = new AlertDialog.Builder(this);
    navBuilder.setIcon(R.mipmap.ic_launcher);
    navBuilder.setTitle(R.string.navMethod);
    navBuilder.setAdapter(adapter, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int navItem) {
            String dlocation = "";
            Intent intent = null;
            switch (navItem) {
            case 0:
                dlocation = String.format("google.navigation:ll=%s,%s&mode=Transit", bahnhof.getLat(),
                        bahnhof.getLon());
                Log.d("findnavigation case 0", dlocation);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(dlocation));
                break;
            case 1:
                dlocation = String.format("google.navigation:ll=%s,%s&mode=d", bahnhof.getLat(),
                        bahnhof.getLon());
                Log.d("findnavigation case 1", dlocation);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(dlocation));
                break;

            case 2:
                dlocation = String.format("google.navigation:ll=%s,%s&mode=b", bahnhof.getLat(),
                        bahnhof.getLon());
                Log.d("findnavigation case 2", dlocation);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(dlocation));
                break;
            case 3:
                dlocation = String.format("google.navigation:ll=%s,%s&mode=w", bahnhof.getLat(),
                        bahnhof.getLon());
                Log.d("findnavigation case 3", dlocation);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(dlocation));
                break;
            case 4:
                dlocation = String.format("geo:0,0?q=%s,%s(%s)", bahnhof.getLat(), bahnhof.getLon(),
                        bahnhof.getTitle());
                Log.d("findnavigation case 4", dlocation);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(dlocation));
                break;

            }
            try {
                startActivity(intent);
            } catch (Exception e) {
                Toast toast = Toast.makeText(context, R.string.activitynotfound, Toast.LENGTH_LONG);
                toast.show();
            }
        }
    }).show();

}