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:org.adawaycn.ui.HostsSourcesFragment.java

/**
 * Add new entry based on input//from  w  ww  .  j  a  v a 2s  . c o  m
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidUrl(input)) {

            // insert hosts source into database
            ProviderHelper.insertHostsSource(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_url_title);
            alertDialog.setMessage(getString(R.string.no_url));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:net.networksaremadeofstring.cyllell.ViewRoles_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    list = (ListView) this.getActivity().findViewById(R.id.rolesListView);
    settings = this.getActivity().getSharedPreferences("Cyllell", 0);
    try {/* www .  j  av  a  2 s  .co  m*/
        Cut = new Cuts(getActivity());
    } catch (Exception e) {
        e.printStackTrace();
    }

    dialog = new ProgressDialog(getActivity());
    dialog.setTitle("Contacting Chef");
    dialog.setMessage("Please wait: Prepping Authentication protocols");
    dialog.setIndeterminate(true);
    if (listOfRoles.size() < 1) {
        dialog.show();
    }

    updateListNotify = new Handler() {
        public void handleMessage(Message msg) {
            int tag = msg.getData().getInt("tag", 999999);

            if (msg.what == 0) {
                if (tag != 999999) {
                    listOfRoles.get(tag).SetSpinnerVisible();
                }
            } else if (msg.what == 1) {
                //Get rid of the lock
                CutInProgress = false;

                //the notifyDataSetChanged() will handle the rest
            } else if (msg.what == 99) {
                if (tag != 999999) {
                    Toast.makeText(ViewRoles_Fragment.this.getActivity(),
                            "An error occured during that operation.", Toast.LENGTH_LONG).show();
                    listOfRoles.get(tag).SetErrorState();
                }
            }
            RoleAdapter.notifyDataSetChanged();
        }
    };

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            //Once we've checked the data is good to use start processing it
            if (msg.what == 0) {
                OnClickListener listener = new OnClickListener() {
                    public void onClick(View v) {
                        GetMoreDetails((Integer) v.getTag());
                    }
                };

                OnLongClickListener listenerLong = new OnLongClickListener() {
                    public boolean onLongClick(View v) {
                        selectForCAB((Integer) v.getTag());
                        return true;
                    }
                };

                RoleAdapter = new RoleListAdaptor(getActivity(), listOfRoles, listener, listenerLong);
                list = (ListView) getView().findViewById(R.id.rolesListView);
                if (list != null) {
                    if (RoleAdapter != null) {
                        list.setAdapter(RoleAdapter);
                    } else {
                        //Log.e("CookbookAdapter","CookbookAdapter is null");
                    }
                } else {
                    //Log.e("List","List is null");
                }

                dialog.dismiss();
            } else if (msg.what == 200) {
                dialog.setMessage("Sending request to Chef...");
            } else if (msg.what == 201) {
                dialog.setMessage("Parsing JSON.....");
            } else if (msg.what == 202) {
                dialog.setMessage("Populating UI!");
            } else {
                //Close the Progress dialog
                dialog.dismiss();

                //Alert the user that something went terribly wrong
                AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
                alertDialog.setTitle("API Error");
                alertDialog.setMessage("There was an error communicating with the API:\n"
                        + msg.getData().getString("exception"));
                alertDialog.setButton2("Back", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        //getActivity().finish();
                    }
                });
                alertDialog.setIcon(R.drawable.icon);
                alertDialog.show();
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            if (listOfRoles.size() > 0) {
                handler.sendEmptyMessage(0);
            } else {
                try {
                    handler.sendEmptyMessage(200);
                    Roles = Cut.GetRoles();
                    handler.sendEmptyMessage(201);

                    JSONArray Keys = Roles.names();

                    for (int i = 0; i < Keys.length(); i++) {
                        listOfRoles.add(new Role(Keys.getString(i), Roles.getString(Keys.getString(i))
                                .replaceFirst("^(https://|http://).*/roles/", "")));
                    }

                    handler.sendEmptyMessage(202);
                    handler.sendEmptyMessage(0);
                } catch (Exception e) {
                    Message msg = new Message();
                    Bundle data = new Bundle();
                    data.putString("exception", e.getMessage());
                    msg.setData(data);
                    msg.what = 1;
                    handler.sendMessage(msg);
                }
            }
            return;
        }
    };

    dataPreload.start();
    return inflater.inflate(R.layout.roles_landing, container, false);
}

From source file:es.uja.photofirma.android.CameraActivity.java

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

    logger.appendLog(100, "login usuario satisfactorio");

    //Definicin de elementos visuales involucrados
    lycpt = (ImageView) findViewById(R.id.cameraActivityCameraPhotoTap);
    lyerr = (LinearLayout) findViewById(R.id.cameraActivityErrorHeader);
    lysuc = (LinearLayout) findViewById(R.id.cameraActivitySuccessHeaderTextView);
    lycan = (LinearLayout) findViewById(R.id.cameraActivityCancelHeader);
    lyinf = (LinearLayout) findViewById(R.id.cameraActivityInfoHeader);
    lyupl = (LinearLayout) findViewById(R.id.cameraActivityUploadingHeader);
    lyudone = (LinearLayout) findViewById(R.id.cameraActivitySuccesUploadHeader);
    lyuerr = (LinearLayout) findViewById(R.id.cameraActivityErrorUploadHeader);
    errorText = (TextView) findViewById(R.id.cameraActivityErrorTextView);

    //gestor de servicios de telefonia, para la obtencin del IMEI del terminal
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    if (telephonyManager == null) {
        imeiNumber = getString(R.string.no_imei_available);
    } else {//  ww  w . j  ava  2 s .  c om
        imeiNumber = telephonyManager.getDeviceId();
    }

    //Deteccin de los parametros necesarios tras un login exitoso
    if (getIntent().hasExtra("userName") && getIntent().hasExtra("userId")
            && getIntent().hasExtra("userEmail")) {
        userName = getIntent().getExtras().getString("userName");
        userId = getIntent().getExtras().getInt("userId");
        userEmail = getIntent().getExtras().getString("userEmail");
    } else {
        Toast.makeText(getApplicationContext(), getString(R.string.no_user_data_found), Toast.LENGTH_LONG)
                .show();
    }

    final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Aviso de privacidad");
    alertDialog.setMessage(getString(R.string.privacy_alert));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();

    SharedPreferences prefs = getSharedPreferences("prefsfile", Context.MODE_PRIVATE);
    String myPrefServerIp = prefs.getString("prefIpAddress", "10.0.3.2");
    URL_CONTENT_UPLOAD = "https://" + myPrefServerIp + "/photo@firmaServices/content_upload.php";
}

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

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == NEWREPO_FLAG) {
        if (data != null && data.hasExtra("update")) {
            final AlertDialog alrt = new AlertDialog.Builder(this).create();
            alrt.setTitle("Update repositories");
            alrt.setMessage("The list of repositories in use has been changed.\nDo you wish to update them?");
            alrt.setButton("Yes", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    updateRepos();//  w  w  w .j av a2s  .  c  o  m
                }
            });
            alrt.setButton2("No", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    alrt.dismiss();
                }
            });
            alrt.show();
        }
    } else if (requestCode == SETTINGS_FLAG) {
        if (data != null && data.hasExtra("align")) {
            order_lst = data.getExtras().getString("align");
            prefEdit.putString("order_lst", order_lst);
            prefEdit.commit();
        }
    }
}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void alertdialog_drivercancelintime() {
    AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
    dcancelbuilder.setMessage("Job has been cancelled.\nPlease look for another driver.");
    dcancelbuilder.setButton("Ok", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            Intent openStart = new Intent("com.TakeTaxi.jy.TakeTaxiActivity");
            startActivity(openStart);//from www .  ja  v  a  2  s .  c  om

        }
    });
    dcancelbuilder.show();
}

From source file:com.aknowledge.v1.automation.RemoteActivity.java

public void showServerAlert() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Can't Connect to server!");
    alertDialog.setMessage("Check your server details under settings");
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }//  w  ww .  j a v  a 2  s  .co m
    });
    // Set the Icon for the Dialog
    alertDialog.show();

}

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

/**
 * Add new entry based on input/* w  w  w.j  ava2 s  .  c o m*/
 *
 * @param input
 */
private void addEntry(String hostname, String ip) {
    if (hostname != null) {
        if (RegexUtils.isValidHostname(hostname)) {
            if (RegexUtils.isValidIP(ip)) {
                ProviderHelper.insertRedirectionListItem(mActivity, 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();
        }
    }
}

From source file:no.ntnu.idi.socialhitchhiking.Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {/*from  www . j a  v  a  2s. co  m*/
        initLoadingScreen();
        new Thread() {
            public void run() {
                setConnection(Main.this);
                user = getApp().getUser();
                if (user == null) {
                    loginButtonClicked();
                } else {
                    initMainScreen();
                    if (!isSession()) {
                        resetSession();
                    }
                }
            }
        }.start();
    } catch (Exception e) {
        AlertDialog ad = new AlertDialog.Builder(Main.this).create();
        ad.setTitle("Server error");
        ad.setMessage(
                "The server is not responding.. Please try again later or contact the system administrator.");
        ad.setButton("Ok", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
                System.exit(0);
            }
        });
        ad.show();
    }

}

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

/**
 * Add new entry based on input/*from  w  w  w . j a va2 s  . c  o m*/
 *
 * @param input
 */
private void addEntry(String hostname, String ip) {
    if (hostname != null) {
        if (RegexUtils.isValidHostname(hostname)) {
            if (RegexUtils.isValidIP(ip)) {
                ProviderHelper.insertRedirectionListItem(mActivity, 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();
        }
    }
}

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

public void onWindowFocusChanged(boolean bool) {
    super.onWindowFocusChanged(bool);
    Log.d("DEBUG", "onWindowFocusChanged");
    if (CreateExampleActivity.create_example_result != null) {
        synchronized (CreateExampleActivity.create_example_result) {
            final AlertDialog dialog = new AlertDialog.Builder(this).create();
            final boolean success = CreateExampleActivity.create_example_result.success();
            dialog.setTitle(CreateExampleActivity.create_example_result.getTitle());
            dialog.setMessage(CreateExampleActivity.create_example_result.getMessage());
            CreateExampleActivity.create_example_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_example.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 back to individual item screen now ...
                        ItemListActivity.loadItem(CreateExampleActivity.this, item_id);
                    }//w w w . ja  v  a  2 s. c  o m
                }
            });
            dialog.show();

        }
    }
}