Example usage for android.app AlertDialog setMessage

List of usage examples for android.app AlertDialog setMessage

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

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  www.j a  v a 2s  .  c  o m
                }
            });
            dialog.show();

        }
    }
}

From source file:sssemil.com.hostsaway.ui.RedirectionListFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info/*from   www.ja v a 2s  .c  om*/
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView hostnameTextView = (TextView) v.findViewWithTag("hostname_" + position);
    TextView ipTextView = (TextView) v.findViewWithTag("ip_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_redirection_dialog, null);
    final EditText hostnameEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    final EditText ipEditText = (EditText) dialogView.findViewById(R.id.list_dialog_ip);

    // set text from list
    hostnameEditText.setText(hostnameTextView.getText());
    ipEditText.setText(ipTextView.getText());

    // move cursor to end of EditText
    Editable hostnameEditContent = hostnameEditText.getText();
    hostnameEditText.setSelection(hostnameEditContent.length());
    Editable ipEditContent = ipEditText.getText();
    ipEditText.setSelection(ipEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String hostname = hostnameEditText.getText().toString();
                    String ip = ipEditText.getText().toString();

                    if (RegexUtils.isValidHostname(hostname)) {
                        if (RegexUtils.isValidIP(ip)) {
                            ProviderHelper.updateRedirectionListItemHostnameAndIp(mActivity, mCurrentRowId,
                                    hostname, ip);
                        } else {
                            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                            alertDialog.setTitle(R.string.no_ip_title);
                            alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_ip));
                            alertDialog.setButton(getString(R.string.button_close),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dlg, int sum) {
                                            dlg.dismiss();
                                        }
                                    });
                            alertDialog.show();
                        }
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.adaway.ui.RedirectionListFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info/* w w w .  j a  v  a  2s  .co m*/
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView hostnameTextView = (TextView) v.findViewWithTag("hostname_" + position);
    TextView ipTextView = (TextView) v.findViewWithTag("ip_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_redirection_dialog, null);
    final EditText hostnameEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    final EditText ipEditText = (EditText) dialogView.findViewById(R.id.list_dialog_ip);

    // set text from list
    hostnameEditText.setText(hostnameTextView.getText());
    ipEditText.setText(ipTextView.getText());

    // move cursor to end of EditText
    Editable hostnameEditContent = hostnameEditText.getText();
    hostnameEditText.setSelection(hostnameEditContent.length());
    Editable ipEditContent = ipEditText.getText();
    ipEditText.setSelection(ipEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String hostname = hostnameEditText.getText().toString();
                    String ip = ipEditText.getText().toString();

                    if (RegexUtils.isValidHostname(hostname)) {
                        if (RegexUtils.isValidIP(ip)) {
                            ProviderHelper.updateRedirectionListItemHostnameAndIp(mActivity, mCurrentRowId,
                                    hostname, ip);
                        } else {
                            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                            alertDialog.setTitle(R.string.no_ip_title);
                            alertDialog.setMessage(getString(org.adaway.R.string.no_ip));
                            alertDialog.setButton(getString(R.string.button_close),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dlg, int sum) {
                                            dlg.dismiss();
                                        }
                                    });
                            alertDialog.show();
                        }
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(org.adaway.R.string.no_hostname));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:net.toload.main.hd.ui.ShareDialog.java

public void confirmShareDialog(final String imtype) {

    AlertDialog alertDialog = new AlertDialog.Builder(activity).create();

    if (imtype.equalsIgnoreCase(Lime.DB_RELATED)) {
        alertDialog.setTitle(activity.getResources().getString(R.string.share_dialog_related_title));
        alertDialog.setMessage(activity.getResources().getString(R.string.share_dialog_related_title_message));
    } else {//from   ww w.j a v  a  2s  . c om
        alertDialog.setTitle(activity.getResources().getString(R.string.share_dialog_title));
        alertDialog.setMessage(activity.getResources().getString(R.string.share_dialog_title_message));
    }
    if (!imtype.equalsIgnoreCase(Lime.DB_RELATED)) {
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                activity.getResources().getString(R.string.share_lime_cin),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (imtype.equals(Lime.DB_RELATED)) {
                            // Call Share IM Processes
                            ((MainActivity) activity).initialShareRelated();
                            dismiss();
                            sharedialog.dismiss();
                        } else {
                            // Call Share IM Processes
                            ((MainActivity) activity).initialShare(imtype);
                            dismiss();
                            sharedialog.dismiss();
                        }
                    }
                });
    }

    alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
            activity.getResources().getString(R.string.share_lime_db), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    if (imtype.equals(Lime.DB_RELATED)) {
                        ((MainActivity) activity).initialShareRelatedDb();
                        dismiss();
                        sharedialog.dismiss();
                    } else {
                        // Call Share IM Processes
                        ((MainActivity) activity).initialShareDb(imtype);
                        dismiss();
                        sharedialog.dismiss();
                    }
                }
            });
    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
            activity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}

From source file:org.adawaycn.ui.RedirectionListFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info/* ww  w.  j  ava2 s  .co m*/
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView hostnameTextView = (TextView) v.findViewWithTag("hostname_" + position);
    TextView ipTextView = (TextView) v.findViewWithTag("ip_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_redirection_dialog, null);
    final EditText hostnameEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    final EditText ipEditText = (EditText) dialogView.findViewById(R.id.list_dialog_ip);

    // set text from list
    hostnameEditText.setText(hostnameTextView.getText());
    ipEditText.setText(ipTextView.getText());

    // move cursor to end of EditText
    Editable hostnameEditContent = hostnameEditText.getText();
    hostnameEditText.setSelection(hostnameEditContent.length());
    Editable ipEditContent = ipEditText.getText();
    ipEditText.setSelection(ipEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String hostname = hostnameEditText.getText().toString();
                    String ip = ipEditText.getText().toString();

                    if (org.adawaycn.util.RegexUtils.isValidHostname(hostname)) {
                        if (org.adawaycn.util.RegexUtils.isValidIP(ip)) {
                            org.adawaycn.provider.ProviderHelper.updateRedirectionListItemHostnameAndIp(
                                    mActivity, mCurrentRowId, hostname, ip);
                        } else {
                            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                            alertDialog.setTitle(R.string.no_ip_title);
                            alertDialog.setMessage(getString(R.string.no_ip));
                            alertDialog.setButton(getString(R.string.button_close),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dlg, int sum) {
                                            dlg.dismiss();
                                        }
                                    });
                            alertDialog.show();
                        }
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(R.string.no_hostname));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.umit.icm.mobile.gui.ControlActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.controlactivity);
    WebsiteSuggestButton = (Button) this.findViewById(R.id.suggestWebsite);
    ServiceSuggestButton = (Button) this.findViewById(R.id.suggestService);
    scanButton = (Button) this.findViewById(R.id.scanButton);
    //        filterButton = (Button) this.findViewById(R.id.filterButton);
    //       servicesFilterButton = (Button) this.findViewById(R.id.serviceFilterButton);
    mapSelectionButton = (Button) this.findViewById(R.id.mapSelectionButton);
    enableTwitterButton = (Button) this.findViewById(R.id.enableTwitterButton);
    bugReportButton = (Button) this.findViewById(R.id.bugReportButton);
    aboutButton = (Button) this.findViewById(R.id.aboutButton);
    scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off));
    try {//from  w ww.j  a  va2 s.co m
        if (Globals.runtimeParameters.getTwitter().equals("Off")) {
            enableTwitterButton.setText(getString(R.string.enable_twitter_button));
        } else {
            enableTwitterButton.setText(getString(R.string.disable_twitter_button));
        }
    } catch (RuntimeException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    BroadcastReceiver receiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals("org.umit.icm.mobile.CONTROL_ACTIVITY")) {
                scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on));
            }
        }
    };

    registerReceiver(receiver, new IntentFilter("org.umit.icm.mobile.CONTROL_ACTIVITY"));

    WebsiteSuggestButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            WebsiteSuggestionDialog websiteSuggestionDialog = new WebsiteSuggestionDialog(ControlActivity.this,
                    "", new OnReadyListener());
            websiteSuggestionDialog.show();
        }

    });

    ServiceSuggestButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            ServiceSuggestionDialog suggestionDialog = new ServiceSuggestionDialog(ControlActivity.this, "",
                    new OnReadyListener());
            suggestionDialog.show();
        }

    });

    enableTwitterButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            try {
                if (Globals.runtimeParameters.getTwitter().equals("Off")) {
                    progressDialog = ProgressDialog.show(ControlActivity.this, getString(R.string.loading),
                            getString(R.string.retrieving_website), true, false);
                    new LaunchBrowser().execute();
                    TwitterDialog twitterDialog = new TwitterDialog(ControlActivity.this, "");
                    twitterDialog.show();
                    enableTwitterButton.setText(getString(R.string.disable_twitter_button));
                } else {
                    Globals.runtimeParameters.setTwitter("Off");
                    enableTwitterButton.setText(getString(R.string.enable_twitter_button));
                }
            } catch (RuntimeException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

    });

    mapSelectionButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            MapSelectionDialog MapSelectionDialog = new MapSelectionDialog(ControlActivity.this, "");
            MapSelectionDialog.show();
        }

    });

    /*      filterButton.setOnClickListener(new OnClickListener() { 
     public void onClick(View v) {                                           
        Intent intent = new Intent(ControlActivity.this, WebsiteFilterActivity.class);                
       startActivity(intent); 
     }
            
           }  );
                  
          servicesFilterButton.setOnClickListener(new OnClickListener() { 
     public void onClick(View v) {                                           
        Intent intent = new Intent(ControlActivity.this, ServiceFilterActivity.class);                
       startActivity(intent); 
     }
            
           }  );*/

    bugReportButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(ControlActivity.this, BugReportActivity.class);
            startActivity(intent);
        }

    });

    aboutButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            String msg = getString(R.string.about_text) + "\n" + getString(R.string.link_to_open_monitor) + "\n"
                    + getString(R.string.link_to_umit) + "\n" + getString(R.string.icons_by);

            final SpannableString spannableString = new SpannableString(msg);
            Linkify.addLinks(spannableString, Linkify.ALL);

            AlertDialog alertDialog = new AlertDialog.Builder(ControlActivity.this).create();
            alertDialog.setTitle(getString(R.string.about_button));
            alertDialog.setMessage(spannableString);
            alertDialog.setIcon(R.drawable.umit_128);
            alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    dialog.dismiss();

                }
            });
            alertDialog.show();

        }

    });

    scanButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (Globals.scanStatus.equalsIgnoreCase(getString(R.string.scan_on))) {
                scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on));
                Globals.scanStatus = getString(R.string.scan_off);
                stopService(new Intent(ControlActivity.this, ConnectivityService.class));
            }

            else {
                scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off));
                Globals.scanStatus = getString(R.string.scan_on);
                startService(new Intent(ControlActivity.this, ConnectivityService.class));
            }

            try {
                Globals.runtimeParameters.setScanStatus(Globals.scanStatus);
            } catch (RuntimeException e) {
                e.printStackTrace();
            }

            Context context = getApplicationContext();
            CharSequence text = getString(R.string.toast_scan_change) + " " + Globals.scanStatus;
            int duration = Toast.LENGTH_SHORT;

            Toast toast = Toast.makeText(context, text, duration);
            toast.show();
        }

    });

}

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

public void onWindowFocusChanged(boolean bool) {
    super.onWindowFocusChanged(bool);
    Log.d("DEBUG", "onWindowFocusChanged");
    if (CreateSoundActivity.create_sound_result != null) {
        synchronized (CreateSoundActivity.create_sound_result) {
            final AlertDialog dialog = new AlertDialog.Builder(this).create();
            final boolean success = CreateSoundActivity.create_sound_result.success();
            dialog.setTitle(CreateSoundActivity.create_sound_result.getTitle());
            dialog.setMessage(CreateSoundActivity.create_sound_result.getMessage());
            CreateSoundActivity.create_sound_result = null;
            dialog.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // TODO avoid moving to item list if previous thread was
                    // interrupted? create_sound.isInterrupted() but need
                    // user to be aware if we
                    // have created sound 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 back to individual item screen now ...
                    ItemListActivity.loadItem(CreateSoundActivity.this, item_id);
                    // }
                    // TODO might want to go to different screens depending
                    // on type of error, e.g. permission issue versus
                    // network
                    // error
                }//from   ww  w .  jav a 2s  . com
            });
            dialog.show();

        }
    }
}

From source file:com.loadsensing.app.LoginActivity.java

public void onClick(View v) {

    // this gets the resources in the xml file
    // and assigns it to a local variable of type EditText
    EditText usernameEditText = (EditText) findViewById(R.id.txt_username);
    EditText passwordEditText = (EditText) findViewById(R.id.txt_password);

    // the getText() gets the current value of the text box
    // the toString() converts the value to String data type
    // then assigns it to a variable of type String
    String sUserName = usernameEditText.getText().toString();
    String sPassword = passwordEditText.getText().toString();

    // Definimos constructor de alerta para los avisos posteriores
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog = new AlertDialog.Builder(this).create();

    // call the backend using Get parameters
    String address = SERVER_HOST + "?user=" + sUserName + "&pass=" + sPassword + "";

    if (sUserName.equals("") || sPassword.equals("")) {
        // error alert
        alertDialog.setTitle(getResources().getString(R.string.error));
        alertDialog.setMessage(getResources().getString(R.string.empty_fields));
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }/*from   w  w  w . j a va 2  s  .  c o m*/
        });
        alertDialog.show();
    } else if (!checkConnection(this.getApplicationContext())) {
        alertDialog.setTitle(getResources().getString(R.string.error));
        alertDialog.setMessage(getResources().getString(R.string.error_no_internet));
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        alertDialog.show();
    } else {
        try {
            showBusyCursor(true);
            progress = ProgressDialog.show(this, getResources().getString(R.string.pantalla_espera_title),
                    getResources().getString(R.string.iniciando_sesion), true);

            Log.d(DEB_TAG, "Requesting to " + address);

            JSONObject json = JsonClient.connectJSONObject(address);

            CheckBox rememberUserPassword = (CheckBox) findViewById(R.id.remember_user_password);
            if (rememberUserPassword.isChecked()) {
                setSharedPreference("login", sUserName);
                setSharedPreference("password", sPassword);
            } else {
                setSharedPreference("login", "");
                setSharedPreference("password", "");
            }

            if (json.getString("session") != "0") {
                progress.dismiss();
                // Guardamos la session en SharedPreferences para utilizarla
                // posteriormente
                setSharedPreference("session", json.getString("session"));
                // Sessin correcta. StartActivity de la home
                Intent intent = new Intent();
                intent.setClass(this.getApplicationContext(), HomeActivity.class);
                startActivity(intent);

            } else {
                progress.dismiss();
                alertDialog.setTitle(getResources().getString(R.string.error));
                alertDialog.setMessage(getResources().getString(R.string.error_login));
                alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
                alertDialog.show();
            }

        } catch (JSONException e) {
            progress.dismiss();
            Log.d(DEB_TAG, "Error parsing data " + e.toString());
        }

        showBusyCursor(false);
    }
}

From source file:semanticweb.hws14.movapp.activities.Criteria.java

private void useLocationData(Location location) {
    //Receive the location Data
    AlertDialog ad = new AlertDialog.Builder(that).create();
    ad.setCancelable(false); // This blocks the 'BACK' button
    Geocoder geocoder = new Geocoder(that, Locale.ENGLISH);
    try {/*  ww w .  j  ava2 s. com*/
        List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);

        if (addresses != null) {
            Address returnedAddress = addresses.get(0);
            final String strReturnedAdress = returnedAddress.getLocality();
            ad.setMessage("You are in: " + strReturnedAdress + "\nUse this location for the search?");

            ad.setButton(DialogInterface.BUTTON_POSITIVE, "YES", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    if (tabPosition == 0) {
                        MovieCriteria currentFragmet = (MovieCriteria) getFragmentByPosition(tabPosition);
                        currentFragmet.setGPSLocation(strReturnedAdress);
                    } else if (tabPosition == 1) {
                        ActorCriteria currentFragmet = (ActorCriteria) getFragmentByPosition(tabPosition);
                        currentFragmet.setGPSLocation(strReturnedAdress);
                    }

                    dialog.dismiss();
                }
            });

            ad.setButton(DialogInterface.BUTTON_NEGATIVE, "NO", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
        } else {
            ad.setMessage("No Address returned!");
            ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
        }
    } catch (IOException e) {
        e.printStackTrace();
        ad.setMessage("Can not get Address!");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
    }

    ad.show();
    setProgressBarIndeterminateVisibility(false);
    locMgr.removeUpdates(locListner);
}

From source file:cm.aptoide.pt.RemoteInTab.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case UPDATE_REPO:
        final AlertDialog upd_alrt = new AlertDialog.Builder(this).create();
        if (!db.areServers()) {
            upd_alrt.setIcon(android.R.drawable.ic_dialog_alert);
            upd_alrt.setTitle("Empty");
            upd_alrt.setMessage(
                    "There are no enabled repositories in your list.\nPlease add repository or enable the ones you have!");
            upd_alrt.setButton("Ok", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                }/*w  w  w. ja v  a2  s.co  m*/
            });
        } else {
            upd_alrt.setIcon(android.R.drawable.ic_dialog_alert);
            upd_alrt.setTitle("Update repositories");
            upd_alrt.setMessage(
                    "Do you wish to update repositories?\nThis can take a while (WiFi is advised)...");
            upd_alrt.setButton("Yes", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    updateRepos();
                }
            });
            upd_alrt.setButton2("No", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    upd_alrt.dismiss();
                }
            });
        }
        upd_alrt.show();
        return true;
    case MANAGE_REPO:
        Intent i = new Intent(this, ManageRepo.class);
        startActivityForResult(i, NEWREPO_FLAG);
        return true;
    case SEARCH_MENU:
        onSearchRequested();
        return true;
    case ABOUT:
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.about, null);
        Builder p = new AlertDialog.Builder(this).setView(view);
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.icon);
        alrt.setTitle("APTOIDE");
        alrt.setButton("ChangeLog", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                Uri uri = Uri.parse("http://aptoide.com/changelog.html");
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
            }
        });
        alrt.show();
        return true;
    case SETTINGS:
        Intent s = new Intent(RemoteInTab.this, Settings.class);
        s.putExtra("order", order_lst);
        startActivityForResult(s, SETTINGS_FLAG);
    }
    return super.onOptionsItemSelected(item);
}