Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:fm.smart.r1.activity.ItemActivity.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // this should be called once image has been chosen by user
    // using requestCode to pass item id - haven't worked out any other way
    // to do it/* w ww.  ja v a2  s.  com*/
    // if (requestCode == SELECT_IMAGE)
    if (resultCode == Activity.RESULT_OK) {
        // TODO check if user is logged in
        if (Main.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            // avoid navigation back to this?
            LoginActivity.return_to = ItemActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("item_id", (String) item.item_node.atts.get("id"));
            startActivity(intent);
            // TODO in this case forcing the user to rechoose the image
            // seems a little
            // rude - should probably auto-submit here ...
        } else {
            // Bundle extras = data.getExtras();
            // String sentence_id = (String) extras.get("sentence_id");
            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Uploading image ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread add_image = new Thread() {
                public void run() {
                    // TODO needs to check for interruptibility

                    String sentence_id = Integer.toString(requestCode);
                    Uri selectedImage = data.getData();
                    // Bitmap bitmap = Media.getBitmap(getContentResolver(),
                    // selectedImage);
                    // ByteArrayOutputStream bytes = new
                    // ByteArrayOutputStream();
                    // bitmap.compress(Bitmap.CompressFormat.JPEG, 40,
                    // bytes);
                    // ByteArrayInputStream fileInputStream = new
                    // ByteArrayInputStream(
                    // bytes.toByteArray());

                    // TODO Might have to save to file system first to get
                    // this
                    // to work,
                    // argh!
                    // could think of it as saving to cache ...

                    // add image to sentence
                    FileInputStream is = null;
                    FileOutputStream os = null;
                    File file = null;
                    ContentResolver resolver = getContentResolver();
                    try {
                        Bitmap bitmap = Media.getBitmap(getContentResolver(), selectedImage);
                        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                        bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
                        // ByteArrayInputStream bais = new
                        // ByteArrayInputStream(bytes.toByteArray());

                        // FileDescriptor fd =
                        // resolver.openFileDescriptor(selectedImage,
                        // "r").getFileDescriptor();
                        // is = new FileInputStream(fd);

                        String filename = "test.jpg";
                        File dir = ItemActivity.this.getDir("images", MODE_WORLD_READABLE);
                        file = new File(dir, filename);
                        os = new FileOutputStream(file);

                        // while (bais.available() > 0) {
                        // / os.write(bais.read());
                        // }
                        os.write(bytes.toByteArray());

                        os.close();

                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } finally {
                        if (os != null) {
                            try {
                                os.close();
                            } catch (IOException e) {
                            }
                        }
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException e) {
                            }
                        }
                    }

                    // File file = new
                    // File(Uri.decode(selectedImage.toString()));

                    // ensure item is in users default list

                    ItemActivity.add_item_result = addItemToList(Main.default_study_list_id,
                            (String) item.item_node.atts.get("id"), ItemActivity.this);
                    Result result = ItemActivity.add_item_result;

                    if (ItemActivity.add_item_result.success()
                            || ItemActivity.add_item_result.alreadyInList()) {

                        // ensure sentence is in users default list

                        ItemActivity.add_sentence_list_result = addSentenceToList(sentence_id,
                                (String) item.item_node.atts.get("id"), Main.default_study_list_id,
                                ItemActivity.this);
                        result = ItemActivity.add_sentence_list_result;
                        if (ItemActivity.add_sentence_list_result.success()) {

                            String media_entity = "http://test.com/test.jpg";
                            String author = "tansaku";
                            String author_url = "http://smart.fm/users/tansaku";
                            Log.d("DEBUG-IMAGE-URI", selectedImage.toString());
                            ItemActivity.add_image_result = addImage(file, media_entity, author, author_url,
                                    "1", sentence_id, (String) item.item_node.atts.get("id"),
                                    Main.default_study_list_id);
                            result = ItemActivity.add_image_result;
                        }
                    }
                    final Result display = result;
                    myOtherProgressDialog.dismiss();
                    ItemActivity.this.runOnUiThread(new Thread() {
                        public void run() {
                            final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create();
                            dialog.setTitle(display.getTitle());
                            dialog.setMessage(display.getMessage());
                            dialog.setButton("OK", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    if (ItemActivity.add_image_result != null
                                            && ItemActivity.add_image_result.success()) {
                                        ItemListActivity.loadItem(ItemActivity.this,
                                                item.item_node.atts.get("id").toString());
                                    }
                                }
                            });

                            dialog.show();
                        }
                    });

                }

            };

            myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    add_image.interrupt();
                }
            });
            OnCancelListener ocl = new OnCancelListener() {
                public void onCancel(DialogInterface arg0) {
                    add_image.interrupt();
                }
            };
            myOtherProgressDialog.setOnCancelListener(ocl);
            closeMenu();
            myOtherProgressDialog.show();
            add_image.start();

        }
    }
}

From source file:fm.smart.r1.activity.CreateItemActivity.java

public void onWindowFocusChanged(boolean bool) {
    super.onWindowFocusChanged(bool);
    Log.d("DEBUG", "onWindowFocusChanged");
    if (CreateItemActivity.create_item_result != null) {
        synchronized (CreateItemActivity.create_item_result) {
            final AlertDialog dialog = new AlertDialog.Builder(this).create();
            final boolean success = CreateItemActivity.create_item_result.success();
            final String item_id = CreateItemActivity.create_item_result.http_response;
            dialog.setTitle(CreateItemActivity.create_item_result.getTitle());
            dialog.setMessage(CreateItemActivity.create_item_result.getMessage());
            CreateItemActivity.create_item_result = null;
            dialog.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // TODO avoid moving to item view if previous thread was
                    // interrupted? create_item.isInterrupted() but need
                    // user to be aware if we
                    // have created example already - progress dialog is set
                    // cancelable, so back button will work? maybe should
                    // avoid encouraging cancel
                    // on POST operations ... not sure what to do if no
                    // response from server - guess we will time out
                    // eventually ...
                    if (success) {
                        // want to go to individual item screen now ...
                        ItemListActivity.loadItem(CreateItemActivity.this, item_id);
                    }//from  w  w w  .j av a 2  s  .com
                }
            });
            dialog.show();

        }
    }
}

From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java

@Override
protected void onServiceBound() {
    T.UI();//from  ww w  .j ava 2s .  c  om
    if (mNotYetProcessedIntent != null) {
        processIntent(mNotYetProcessedIntent);
        mNotYetProcessedIntent = null;
    }

    setContentView(R.layout.registration2);

    //Apply Fonts
    TextUtils.overrideFonts(this, findViewById(android.R.id.content));

    final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf");
    final int[] visibleLogos;
    final int[] goneLogos;
    if (AppConstants.FULL_WIDTH_HEADERS) {
        visibleLogos = FULL_WIDTH_ROGERTHAT_LOGOS;
        goneLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS;
        View viewFlipper = findViewById(R.id.registration_viewFlipper);
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) viewFlipper.getLayoutParams();
        params.setMargins(0, 0, 0, 0);
    } else {
        visibleLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS;
        goneLogos = FULL_WIDTH_ROGERTHAT_LOGOS;
    }

    for (int id : visibleLogos)
        findViewById(id).setVisibility(View.VISIBLE);
    for (int id : goneLogos)
        findViewById(id).setVisibility(View.GONE);

    handleScreenOrientation(getResources().getConfiguration().orientation);

    ScrollView rc = (ScrollView) findViewById(R.id.registration_container);
    Resources resources = getResources();
    if (CloudConstants.isRogerthatApp()) {
        rc.setBackgroundColor(resources.getColor(R.color.mc_page_dark));
    } else {
        rc.setBackgroundColor(resources.getColor(R.color.mc_homescreen_background));
    }

    TextView rogerthatWelcomeTextView = (TextView) findViewById(R.id.rogerthat_welcome);

    TextView tosTextView = (TextView) findViewById(R.id.registration_tos);
    Typeface FONT_THIN_ITALIC = Typeface.createFromAsset(getAssets(), "fonts/lato_light_italic.ttf");
    tosTextView.setTypeface(FONT_THIN_ITALIC);
    tosTextView.setTextColor(ContextCompat.getColor(RegistrationActivity2.this, R.color.mc_words_color));

    Button agreeBtn = (Button) findViewById(R.id.registration_agree_tos);

    TextView tvRegistration = (TextView) findViewById(R.id.registration);
    tvRegistration.setText(getString(R.string.registration_city_app_sign_up, getString(R.string.app_name)));

    mEnterEmailAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.registration_enter_email);

    if (CloudConstants.isEnterpriseApp()) {
        rogerthatWelcomeTextView
                .setText(getString(R.string.rogerthat_welcome_enterprise, getString(R.string.app_name)));
        tosTextView.setVisibility(View.GONE);
        agreeBtn.setText(R.string.start_registration);
        mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint_enterprise);
    } else {
        rogerthatWelcomeTextView
                .setText(getString(R.string.registration_welcome_text, getString(R.string.app_name)));

        tosTextView.setText(Html.fromHtml(
                "<a href=\"" + CloudConstants.TERMS_OF_SERVICE_URL + "\">" + tosTextView.getText() + "</a>"));
        tosTextView.setMovementMethod(LinkMovementMethod.getInstance());

        agreeBtn.setText(R.string.registration_btn_agree_tos);

        mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint);
    }

    agreeBtn.getBackground().setColorFilter(Message.GREEN_BUTTON_COLOR, PorterDuff.Mode.MULTIPLY);
    agreeBtn.setOnClickListener(new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_AGREED_TOS);
            mWiz.proceedToNextPage();

        }
    });

    initLocationUsageStep(faTypeFace);

    View.OnClickListener emailLoginListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_EMAIL_LOGIN);
            mWiz.proceedToNextPage();
        }
    };

    findViewById(R.id.login_via_email).setOnClickListener(emailLoginListener);

    Button facebookButton = (Button) findViewById(R.id.login_via_fb);

    View.OnClickListener facebookLoginListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check network connectivity
            if (!mService.getNetworkConnectivityManager().isConnected()) {
                UIUtils.showNoNetworkDialog(RegistrationActivity2.this);
                return;
            }

            sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_FACEBOOK_LOGIN);

            FacebookUtils.ensureOpenSession(RegistrationActivity2.this,
                    AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE
                            ? Arrays.asList("email", "user_friends", "user_birthday")
                            : Arrays.asList("email", "user_friends"),
                    PermissionType.READ, new Session.StatusCallback() {
                        @Override
                        public void call(Session session, SessionState state, Exception exception) {
                            if (session != Session.getActiveSession()) {
                                session.removeCallback(this);
                                return;
                            }

                            if (exception != null) {
                                session.removeCallback(this);
                                if (!(exception instanceof FacebookOperationCanceledException)) {
                                    L.bug("Facebook SDK error during registration", exception);
                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                            RegistrationActivity2.this);
                                    builder.setMessage(R.string.error_please_try_again);
                                    builder.setPositiveButton(R.string.rogerthat, null);
                                    AlertDialog dialog = builder.create();
                                    dialog.show();
                                }
                            } else if (session.isOpened()) {
                                session.removeCallback(this);
                                if (session.getPermissions().contains("email")) {
                                    registerWithAccessToken(session.getAccessToken());
                                } else {
                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                            RegistrationActivity2.this);
                                    builder.setMessage(R.string.facebook_registration_email_missing);
                                    builder.setPositiveButton(R.string.rogerthat, null);
                                    AlertDialog dialog = builder.create();
                                    dialog.show();
                                }
                            }
                        }
                    }, false);
        }

        ;
    };

    facebookButton.setOnClickListener(facebookLoginListener);

    final Button getAccountsButton = (Button) findViewById(R.id.get_accounts);
    if (configureEmailAutoComplete()) {
        // GET_ACCOUNTS permission is granted
        getAccountsButton.setVisibility(View.GONE);
    } else {
        getAccountsButton.setTypeface(faTypeFace);
        getAccountsButton.setOnClickListener(new SafeViewOnClickListener() {
            @Override
            public void safeOnClick(View v) {
                ActivityCompat.requestPermissions(RegistrationActivity2.this,
                        new String[] { Manifest.permission.GET_ACCOUNTS }, PERMISSION_REQUEST_GET_ACCOUNTS);
            }
        });
    }

    mEnterPinEditText = (EditText) findViewById(R.id.registration_enter_pin);

    mEnterPinEditText.addTextChangedListener(new TextWatcher() {

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

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

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() == PIN_LENGTH)
                onPinEntered();
        }
    });

    Button requestNewPinButton = (Button) findViewById(R.id.registration_request_new_pin);
    requestNewPinButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mWiz.setEmail(null);
            hideNotification();
            mWiz.reInit();
            mWiz.goBackToPrevious();
            mEnterEmailAutoCompleteTextView.setText("");
        }
    });

    mWiz = RegistrationWizard2.getWizard(mService);
    mWiz.setFlipper((ViewFlipper) findViewById(R.id.registration_viewFlipper));
    setFinishHandler();
    addAgreeTOSHandler();
    addIBeaconUsageHandler();
    addChooseLoginMethodHandler();
    addEnterPinHandler();
    mWiz.run();
    mWiz.setDeviceId(Installation.id(this));

    handleEnterEmail();

    if (mWiz.getBeaconRegions() != null && mBeaconManager == null) {
        bindBeaconManager();
    }

    if (CloudConstants.USE_GCM_KICK_CHANNEL && GoogleServicesUtils.checkPlayServices(this, true)) {
        GoogleServicesUtils.registerGCMRegistrationId(mService, new GCMRegistrationIdFoundCallback() {
            @Override
            public void idFound(String registrationId) {
                mGCMRegistrationId = registrationId;
            }
        });
    }
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void RunChoice() {

    storage = CachingStorage.getInstance();
    config = storage.loadScheduleConfig();
    // if config == null the app is not been activate and
    // no test can be run
    if (config == null) {
        // TODO Add an alert that the app has not been init yet
        config = new ScheduleConfig();
    }/*from  w w  w  .  j  a  v  a 2s.c o m*/
    testList = config.manual_tests;
    array_spinner = new String[testList.size() + 1];
    array_spinner_int = new int[testList.size() + 1];

    Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.choose_test));
    // dropdown setup

    for (int i = 0; i < testList.size(); i++) {
        TestDescription td = testList.get(i);
        array_spinner[i] = td.displayName;
        array_spinner_int[i] = td.testId;
    }
    array_spinner[testList.size()] = getString(R.string.all);
    array_spinner_int[testList.size()] = -1;

    builder.setItems(array_spinner, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            dialog.dismiss();

            Intent intent = new Intent(SamKnowsAggregateStatViewerActivity.this,
                    SamKnowsTestViewerActivity.class);
            Bundle b = new Bundle();
            b.putInt("testID", array_spinner_int[which]);
            intent.putExtras(b);
            startActivityForResult(intent, 1);
            overridePendingTransition(R.anim.transition_in, R.anim.transition_out);
        }
    });
    builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void SingleChoice() {
    Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.choose_time));
    // dropdown setup
    final String array_spinner[];

    array_spinner = new String[4];
    array_spinner[0] = getString(R.string.time_period_1week);
    array_spinner[1] = getString(R.string.time_period_1month);
    array_spinner[2] = getString(R.string.time_period_3months);
    array_spinner[3] = getString(R.string.time_period_1year);

    builder.setItems(array_spinner, new DialogInterface.OnClickListener() {
        @Override//  w w  w .j  a va 2  s.com
        public void onClick(DialogInterface dialog, int which) {

            int weeks = 0;

            if (array_spinner[which] == getString(R.string.time_period_1week)) {
                weeks = 1;
            }
            if (array_spinner[which] == getString(R.string.time_period_1month)) {
                weeks = 4;
            }
            if (array_spinner[which] == getString(R.string.time_period_3months)) {
                weeks = 12;
            }
            if (array_spinner[which] == getString(R.string.time_period_1year)) {
                weeks = 52;
            }

            TextView tvHeader = (TextView) findViewById(R.id.timeperiod);
            tvHeader.setText(array_spinner[which]);

            loadAverage(weeks);

            Calendar now = Calendar.getInstance();
            long current_dtime = now.getTimeInMillis();
            now.add(Calendar.WEEK_OF_YEAR, weeks * -1);
            long starting_dtime = now.getTimeInMillis();

            // update charts
            data = new JSONObject();

            data = dbHelper.getGraphData(TestResult.DOWNLOAD_TEST_ID, starting_dtime, current_dtime);
            graphHandler1.setData(data);
            graphHandler1.update();

            data = dbHelper.getGraphData(TestResult.UPLOAD_TEST_ID, starting_dtime, current_dtime);
            graphHandler2.setData(data);
            graphHandler2.update();

            data = dbHelper.getGraphData(TestResult.LATENCY_TEST_ID, starting_dtime, current_dtime);
            graphHandler3.setData(data);
            graphHandler3.update();

            data = dbHelper.getGraphData(TestResult.PACKETLOSS_TEST_ID, starting_dtime, current_dtime);
            graphHandler4.setData(data);
            graphHandler4.update();

            data = dbHelper.getGraphData(TestResult.JITTER_TEST_ID, starting_dtime, current_dtime);
            graphHandler5.setData(data);
            graphHandler5.update();

            dialog.dismiss();
        }
    });
    builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.fvd.nimbus.BrowseActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // if statement prevents force close error when picture isn't selected
    if (progressDialog != null) {
        progressDialog.dismiss();/*from   w w w .j a v a 2s . com*/
    }
    if (requestCode == 6) {
        serverHelper.getInstance().setCallback(this, this);
        saveCSS = prefs.getString("clipStyle", "1").equals("1");
        //Log.i("nimbus",saveCSS==true?"true":"false");
        wv.eval(String.format("javascript:android.fvdSaveCss(%s)", saveCSS == true ? "true" : "false"));
        if ("1".equals(prefs.getString("userAgent", "1"))) {
            wv.setUserAgent(null);
        } else
            wv.setUserAgent(deskAgent);
    } else if (requestCode == 3) {
        if (resultCode == RESULT_OK || resultCode == RESULT_FIRST_USER) {
            userMail = data.getStringExtra("userMail");
            userPass = data.getStringExtra("userPass");
            //sendRequest("user:auth", String.format("\"email\":\"%s\",\"password\":\"%s\"",userMail,userPass));
            if (resultCode == RESULT_OK)
                sendRequest("user:auth",
                        String.format("\"email\":\"%s\",\"password\":\"%s\"", userMail, userPass));
            else
                serverHelper.getInstance().sendOldRequest("user_register", String.format(
                        "{\"action\": \"user_register\",\"email\":\"%s\",\"password\":\"%s\",\"_client_software\": \"ff_addon\"}",
                        userMail, userPass), "");
        }
    } else if (requestCode == 4) {
        if (resultCode == RESULT_OK) {
            if (serverHelper.getInstance().canShare()) {
                serverHelper.getInstance().shareNote();
            }
        }
    } else if (requestCode == 5) {
        if (resultCode == RESULT_OK) {
            DataExchange cl = (DataExchange) data.getExtras().getSerializable("content");
            if (sessionId.length() == 0 || userPass.length() == 0)
                showSettings();
            else {
                if (prefs.getBoolean("check_fast", false)) {
                    sendNote(wv.getTitle(), cl.getContent(), parent, tag);
                    clipData.setContent("");
                } else {
                    serverHelper.getInstance().setCallback(this, this);
                    if (appSettings.sessionId.length() > 0) {
                        serverHelper.getInstance().sendRequest("notes:getFolders", "", "");
                    }
                }
            }
        }
        wv.endSelectionMode();
    } else if (requestCode == 11) {
        if (appSettings.sessionId != "") {
            sessionId = appSettings.sessionId;
            userPass = appSettings.userPass;
            if (lastAction != "") {
                serverHelper.getInstance().sendRequest(lastAction, "", "");
            } else if (clipData != null && clipData.getContent().length() > 0) {
                if (prefs.getBoolean("check_fast", false)) {
                    sendNote(clipData.getTitle(), clipData.getContent(), parent, tag);
                    clipData.setContent("");
                } else {
                    serverHelper.getInstance().setCallback(this, this);
                    if (appSettings.sessionId.length() > 0) {
                        serverHelper.getInstance().sendRequest("notes:getFolders", "", "");
                    }
                }
            }
        }
    } else if (requestCode == 7) {

        if (resultCode == RESULT_OK && data != null) {
            try {
                DataExchange xdata = (DataExchange) data.getExtras().getSerializable("xdata");
                parent = xdata.getId();
                tag = xdata.getTags();
                String xtitle = xdata.getTitle();
                clipData.setTitle(xtitle);
                //clipData.setTags(tag);
                if (sessionId.length() == 0 || userPass.length() == 0)
                    showSettings();
                else {
                    sendNote(xtitle, clipData.getContent(), parent, tag);
                    clipData.setContent("");
                }
            } catch (Exception e) {
                BugReporter.Send("BrowseAct", e.getMessage());
            }
        }

    } else if (requestCode == SHOW_SETTINGS) {
        switch (resultCode) {
        case RESULT_FIRST_USER + 1:
            Intent i = new Intent(getApplicationContext(), PrefsActivity.class);
            startActivity(i);

            overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
            break;
        case RESULT_FIRST_USER + 2:
            if (appSettings.sessionId.length() == 0)
                showLogin();
            else {
                appSettings.sessionId = "";
                //serverHelper.getInstance().setSessionId(appSettings.sessionId);
                Editor e = prefs.edit();
                e.putString("userMail", userMail);
                e.putString("userPass", "");
                e.putString("sessionId", appSettings.sessionId);
                e.commit();
                showLogin();
            }
            break;
        case RESULT_FIRST_USER + 3:
            try {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("market://details?id=" + getApplicationInfo().packageName)));
            } catch (Exception e) {
            }
        case RESULT_FIRST_USER + 4:
            Uri uri = Uri.parse(
                    "http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide");
            Intent it = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(it);
            //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
            overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
            break;
        case RESULT_FIRST_USER + 5:
            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this,
                    AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            alertDialogBuilder.setMessage(getScriptContent("license.txt")).setCancelable(false)
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // no alert dialog shown
                            //alertDialogShown = null;
                            // canceled
                            setResult(RESULT_CANCELED);
                            // and finish
                            //finish();
                        }
                    });
            // create alert dialog
            final AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.setTitle(getString(R.string.license_title));

            // and show
            //alertDialogShown = alertDialog;
            try {
                alertDialog.show();
            } catch (final java.lang.Exception e) {
                // nothing to do
            } catch (final java.lang.Error e) {
                // nothing to do
            }
            break;
        default:
            break;
        }
    }
}

From source file:activities.PaintActivity.java

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

    AlertDialog avisoDialog = builder.setCancelable(false).setMessage(aviso_paleta)
            .setPositiveButton(aviso_paleta_ok, new DialogInterface.OnClickListener() {
                @Override/*from w w  w . j a  va 2  s . c om*/
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            }).create();

    avisoDialog.show();
}

From source file:ac.robinson.mediaphone.MediaPhoneActivity.java

private void onBackgroundTaskProgressUpdate(int taskId) {
    // dismiss dialogs first so we don't leak if onBackgroundTaskCompleted finishes the activity
    if (mBackgroundRunnerDialogShown) {
        safeDismissDialog(R.id.dialog_background_runner_in_progress);
        mBackgroundRunnerDialogShown = false;
    }/*  w w  w  .  ja v a  2s  .  co  m*/

    // report any task results
    onBackgroundTaskCompleted(taskId);

    // alert when template creation is complete - here as template creation can happen in several places
    // don't do this from template browser as in that case we're copying the other way (i.e. creating narrative)
    if (taskId == R.id.make_load_template_task_complete
            && !(MediaPhoneActivity.this instanceof TemplateBrowserActivity)
            && !MediaPhoneActivity.this.isFinishing()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(MediaPhoneActivity.this);
        builder.setTitle(R.string.make_template_confirmation);
        builder.setMessage(R.string.make_template_hint);
        builder.setIcon(android.R.drawable.ic_dialog_info);
        builder.setPositiveButton(android.R.string.ok, null);
        AlertDialog alert = builder.create();
        alert.show();
    }
}