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:org.schtief.partybolle.event.EventManager.java

public void getEvents(String type) {
    GeoPoint center = mapView.getMapCenter();

    //check for Events in Berlin
    if (center.getLatitudeE6() < 52000000 || center.getLatitudeE6() > 53000000
            || center.getLongitudeE6() < 13000000 || center.getLongitudeE6() > 14000000) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this.app);
        builder.setMessage("Alder ick komm aus Berlin, keene Ahnung wat in deinem Kaff los ist!")
                .setCancelable(false)/*from w w  w . j  a va  2s  .c o  m*/
                .setPositiveButton("Ich helf dir mit Events fr hier", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                        //TODO twidroid ansprechen
                    }
                }).setNegativeButton("Ok OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
    }
    int lat1 = center.getLatitudeE6() - mapView.getLatitudeSpan() / 2;
    int lat2 = center.getLatitudeE6() + mapView.getLatitudeSpan() / 2;

    int lon1 = center.getLongitudeE6() - mapView.getLongitudeSpan() / 2;
    int lon2 = center.getLongitudeE6() + mapView.getLongitudeSpan() / 2;

    new GetEventsThread(lat1, lon1, lat2, lon2, type).start();
}

From source file:au.org.ala.fielddata.mobile.SpeciesListActivity.java

public void onSpeciesSelected(final Species species) {

    final List<Survey> surveys = getSurveys(species);
    final String[] items = buildMenuItems(surveys);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(getString(R.string.species_action_title));
    builder.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            if (item > 0) {
                recordObservation(species, surveys.get(item - 1));
            } else {
                showFieldGuide(species);
            }//from  w  w  w  .  ja  v  a 2 s.  c  om
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:de.thecamper.android.androidtools.UpdateChecker.java

/**
 * show a AlertDialog to inform the user of the update and let him download
 * the new version of the app/*from w w w  .  j a  v a2s  .  c  om*/
 */
public void showUpdateAlert() {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(context.getString(R.string.updateTitle));
    builder.setMessage(context.getString(R.string.updateAvailable));
    builder.setCancelable(false);
    builder.setPositiveButton(context.getString(R.string.yes), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(appURL));
            context.startActivity(intent);
            ((Activity) context).finish();
        }
    });
    builder.setNegativeButton(context.getString(R.string.later), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.star.printer.StarPrinter.java

/**
 * This function shows how to get the firmware information of a printer
 * /*from www.  j  a  va2s.c  o m*/
 * @param context
 *            Activity for displaying messages to the user
 * @param portName
 *            Port name to use for communication. This should be
 *            (TCP:<IPAddress> or BT:<DeviceName> for bluetooth)
 * @param portSettings
 *            Should be mini, the port settings mini is used for portable
 *            printers
 */
public static void CheckFirmwareVersion(Context context, String portName, String portSettings) {
    StarIOPort port = null;
    try {
        /*
         * using StarIOPort3.1.jar (support USB Port) Android OS Version:
         * upper 2.2
         */
        port = StarIOPort.getPort(portName, portSettings, 10000, context);
        /*
         * using StarIOPort.jar Android OS Version: under 2.1 port =
         * StarIOPort.getPort(portName, portSettings, 10000);
         */

        // A sleep is used to get time for the socket to completely open
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        }

        Map<String, String> firmware = port.getFirmwareInformation();

        String modelName = firmware.get("ModelName");
        String firmwareVersion = firmware.get("FirmwareVersion");

        String message = "Model Name:" + modelName;
        message += "\nFirmware Version:" + firmwareVersion;

        Builder dialog = new AlertDialog.Builder(context);
        dialog.setNegativeButton("Ok", null);
        AlertDialog alert = dialog.create();
        alert.setTitle("Firmware Information");
        alert.setMessage(message);
        alert.setCancelable(false);
        alert.show();

    } catch (StarIOPortException e) {
        Builder dialog = new AlertDialog.Builder(context);
        dialog.setNegativeButton("Ok", null);
        AlertDialog alert = dialog.create();
        alert.setTitle("Failure");
        alert.setMessage("Failed to connect to printer");
        alert.setCancelable(false);
        alert.show();
    } finally {
        if (port != null) {
            try {
                StarIOPort.releasePort(port);
            } catch (StarIOPortException e) {
            }
        }
    }
}

From source file:com.mono.applink.Foursquare.java

/** Called when the activity is first created. */
@Override//ww w  . j a va  2 s . c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final String url = getIntent().getData().toString();

    if (url.contains("user"))//user with id
    {
        new FoursquareUser().execute();
    } else if (url.contains("venue")) {
        new FoursquareVenue().execute();
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("Sorry, but this type of link is not currently supported");
        builder.setOnCancelListener(new OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Intent i = new Intent();
                i.setAction("android.intent.action.VIEW");
                i.addCategory("android.intent.category.BROWSABLE");
                i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                i.setData(Uri.parse(url));
                startActivity(i);
                finish();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }

}

From source file:com.springsource.greenhouse.twitter.PostTweetActivity.java

private void showResult(String result) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(result);/*w ww.  j a v  a  2  s . co m*/
    builder.setCancelable(false);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.mono.applink.Twitter.java

/** Called when the activity is first created. */
@Override/*from w w w . j a  v  a2  s  .  co  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final String url = getIntent().getData().toString();

    if (url.contains("twitter.com") && !url.contains("status") && !url.contains("direct_messages")
            && !url.contains("user_spam_reports") && !url.contains("account") && !url.contains("settings"))//Just if it is a link of a user profile
    {
        new TwitterUser().execute();
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("Sorry, but this type of link is not currently supported");
        builder.setOnCancelListener(new OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Intent i = new Intent();
                i.setAction("android.intent.action.VIEW");
                i.addCategory("android.intent.category.BROWSABLE");
                i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                i.setData(Uri.parse(url));
                startActivity(i);
                finish();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
}

From source file:com.springsource.greenhouse.events.sessions.EventSessionRatingActivity.java

private void showSelectStarRatingDialog() {
    final CharSequence[] items = { "5 Stars", "4 Stars", "3 Stars", "2 Stars", "1 Star" };
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Select a Star Value");
    builder.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            setRating(5 - item);/*from  ww  w .  j a v a2s .co m*/
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.springsource.greenhouse.events.sessions.EventSessionRatingActivity.java

private void showResult(String result) {
    //      Toast.makeText(this, result, Toast.LENGTH_LONG).show();
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(result);//from ww  w. j  a  va 2s . c  o m
    builder.setCancelable(false);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixState.java

public void DialogSelectOption(final MixContext ctx, final String markerTitle, final PhysicalPlace log,
        final String onPress) {
    final String items[] = { "?  ", "?" };
    AlertDialog.Builder ab = new AlertDialog.Builder(ctx);
    ab.setTitle(markerTitle);//from   w ww.j av a 2 s. c o m
    ab.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // ? 
            Toast.makeText(ctx, items[id] + " ?.", Toast.LENGTH_SHORT).show();
            dialog.dismiss();

            if (id == 0) {
                try {
                    ctx.loadMixViewWebPage(onPress);
                } catch (Exception e) {
                }
            } else if (id == 1) {
                Navigator navigator = Navigator.getNavigator();
                if (navigator != null)
                    navigator.run(log.getLatitude(), log.getLongitude());
                else
                    Toast.makeText(ctx, "? ?   .",
                            Toast.LENGTH_LONG).show();
            }

        }
    });
    // ? ?
    AlertDialog alertDialog = ab.create();
    // ? 
    alertDialog.show();
}