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:net.evecom.android.web.Web0Activity.java

/**
 * /*from  w ww .  j  a  va  2s .  c o  m*/
 * 
 * @param v
 */
public void message_post_web_tomain(View v) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(Web0Activity.this);
    builder1.setTitle("");
    builder1.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder1.setMessage("");
    builder1.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }
    });
    builder1.setNegativeButton("", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    builder1.show();
}

From source file:com.github.socialc0de.gsw.android.MainActivity.java

/**
 * Handles the results from activities launched to select an account and to install Google Play
 * Services.// w w w . ja va  2 s  .  c om
 */

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_ACCOUNT_PICKER:
        if (data != null && data.getExtras() != null) {
            String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME);
            if (accountName != null) {
                onSignedIn(accountName);
            }
        } else if (!SIGN_IN_REQUIRED) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle(R.string.are_you_sure);
            alert.setMessage(R.string.not_all_features);
            alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    startMainActivity();
                }
            });
            alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
                }
            });
            alert.show();

        }
        break;
    case REQUEST_GOOGLE_PLAY_SERVICES:
        if (resultCode != Activity.RESULT_OK) {
            checkGooglePlayServicesAvailable();
        }
        break;
    }

    if (requestCode == REQUEST_CODE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
            if (confirm != null) {
                try {
                    Log.i(TAG, confirm.toJSONObject().toString(4));
                    Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));
                    /**
                     *  TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
                     * or consent completion.
                     * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                     * for more details.
                     *
                     * For sample mobile backend interactions, see
                     * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
                     */
                    Toast.makeText(getApplicationContext(), "PaymentConfirmation info received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled.");
        } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
        }
    } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PayPalAuthorization auth = data
                    .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION);
            if (auth != null) {
                try {
                    Log.i("FuturePaymentExample", auth.toJSONObject().toString(4));

                    String authorization_code = auth.getAuthorizationCode();
                    Log.i("FuturePaymentExample", authorization_code);

                    Toast.makeText(getApplicationContext(), "Future Payment code received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("FuturePaymentExample", "The user canceled.");
        } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i("FuturePaymentExample",
                    "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
        }
    } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) {
        if (resultCode == Activity.RESULT_OK) {
            PayPalAuthorization auth = data
                    .getParcelableExtra(PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION);
            if (auth != null) {
                try {
                    Log.i("ProfileSharingExample", auth.toJSONObject().toString(4));

                    String authorization_code = auth.getAuthorizationCode();
                    Log.i("ProfileSharingExample", authorization_code);

                    Toast.makeText(getApplicationContext(), "Profile Sharing code received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e("ProfileSharingExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("ProfileSharingExample", "The user canceled.");
        } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i("ProfileSharingExample",
                    "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
        }
    }
}

From source file:net.evecom.android.log.DailyLogLookActivity.java

/**
 * //from  w  w w . ja  va 2 s .  c  o m
 * 
 * @param v
 */
public void daily_log_more_delete(View v) {

    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogLookActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(DailyLogLookActivity.this, "", "...");

            formSubmit1();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();

}

From source file:uk.bowdlerize.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getActionBar().setTitle(getString(R.string.actionBarTitle));
    getActionBar().setSubtitle(getString(R.string.actionBarSubtitle));

    settings = getGCMPreferences(this);

    //Check if the user has agreed
    if (settings.getBoolean("agreed", false)) {
        onConfirmed();/*w w  w .  j  a  v  a  2  s.  c  o m*/
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.warningMessage).setTitle(R.string.warningTitle);
        builder.setPositiveButton(R.string.warningAgree, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                SharedPreferences.Editor editor = settings.edit();
                editor.putBoolean("agreed", true);
                editor.commit();
                dialog.dismiss();
                Toast.makeText(MainActivity.this, getString(R.string.warningAgreed), Toast.LENGTH_SHORT).show();
                configureTabs();
            }
        });
        builder.setNegativeButton(R.string.warningExit, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
                finish();
            }
        });
        builder.show();
    }
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_purchase_ad:
        startBuyFlow();/*from ww w.ja  v a 2 s. c o  m*/
        return true;
    case R.id.action_discover_wtc:
        final String TRAILER = this.getResources().getString(R.string.youtube_video_trailer);
        final String ANNIV = this.getResources().getString(R.string.youtube_video_anniv);
        CharSequence[] items = new CharSequence[] { getString(R.string.video_trailer_name),
                getString(R.string.video_2ans_name) };
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.choose_video));
        builder.setItems(items, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                case 0:
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(TRAILER)));
                    break;
                case 1:
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(ANNIV)));
                    break;
                }
            }
        });
        builder.show();
        return true;
    case R.id.action_facebook_app:
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.facebook_bad))));
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:at.jclehner.rxdroid.DrugEditFragment.java

private void showDrugDeleteDialog() {
    final String message = getString(R.string._title_delete_item, mWrapper.get().getName()) + " "
            + getString(R.string._msg_delete_drug);

    final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());

    ab.setIcon(android.R.drawable.ic_dialog_alert);
    ab.setMessage(message);//from  www. j  a  v  a  2 s  .co  m
    ab.setNegativeButton(android.R.string.no, null);
    ab.setPositiveButton(android.R.string.yes, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Database.delete(mWrapper.get());
            Toast.makeText(getActivity(), R.string._toast_deleted, Toast.LENGTH_SHORT).show();
            getActivity().finish();
        }
    });

    ab.show();
}

From source file:com.code.android.vibevault.SearchScreen.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.nowPlaying: //Open playlist activity
        Intent np = new Intent(SearchScreen.this, NowPlayingScreen.class);
        //Intent np = new Intent(SearchScreen.this, HomeScreen.class);

        startActivity(np);/*  w ww .  j a  v a 2s  . c o m*/
        break;
    case R.id.recentShows:
        Intent rs = new Intent(SearchScreen.this, RecentShowsScreen.class);

        startActivity(rs);
        break;
    case R.id.scrollableDialog:
        AlertDialog.Builder ad = new AlertDialog.Builder(this);
        ad.setTitle("Help!");
        View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null);
        ((TextView) v.findViewById(R.id.DialogText)).setText(R.string.search_screen_help);
        ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int arg1) {
            }
        });
        ad.setView(v);
        ad.show();
    }
    return true;
}

From source file:com.ccxt.whl.activity.SettingsFragmentCopy.java

/**
 * ?/*ww  w.ja va 2  s  . c o m*/
 */
public void change_headurl() {
    //SDcard
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        //SDcardTestSyncListView
        IMAGE_FILE_LOCATION = Environment.getExternalStorageDirectory() + Constant.CACHE_DIR_IMAGE
                + "/temp.jpg";
        imageUri = Uri.parse(IMAGE_FILE_LOCATION);
        //File cutFile = new File(Constant.CACHE_DIR_IMAGE,"temp.jpg");
        //cutFile.getParentFile().mkdirs();
        File dir = new File(IMAGE_FILE_LOCATION);
        if (!dir.exists()) {
            try {
                //  
                dir.createNewFile();
            } catch (Exception e) {
                //println(e);
            }
        }
    } else {
        Toast.makeText(getActivity(), "SD????", 0).show();
        return;
    }
    AlertDialog.Builder builder = new Builder(getActivity());
    String[] strarr = { "?", "" };
    builder.setItems(strarr, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            // TODO ? 
            if (arg1 == 0) {//?
                selectPicFromCamera();
            } else {//
                selectPicFromLocal();
            }
        }
    });
    builder.show();
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

public void deleteBeacon(int position) {
    final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr();

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("  ?");
    alertDialog.setMessage("? ? ?");
    alertDialog.setIcon(R.drawable.alert);

    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            updateEvent("BEACON_DELETE");
            DeleteBeacon deleteBeacon = new DeleteBeacon();
            deleteBeacon.execute("http://125.131.73.198:3000/beconDelete", beaconmac);
        }//from   w ww.  j a  v a  2  s  . c om
    });

    alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    alertDialog.show();
}

From source file:net.evecom.android.log.DailyLogLookActivity.java

/**
 * /*from  w  w w. j  av  a2  s.co m*/
 */
private String submit() {
    /**  */
    if (btEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (gzsjButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rzlxButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rznrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (years > calendar.get(Calendar.YEAR)) {
        DialogToast("");
        return "";
    } else if (years == calendar.get(Calendar.YEAR)) {
        if (month > calendar.get(Calendar.MONTH) + 1) {
            DialogToast("");
            return "";
        } else if (month == calendar.get(Calendar.MONTH) + 1) {
            if (day > calendar.get(Calendar.DAY_OF_MONTH)) {
                DialogToast("");
                return "";
            }
        }
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogLookActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(DailyLogLookActivity.this, "", "...");

            formSubmit();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
    return "1";
}