Example usage for android.app ProgressDialog setMessage

List of usage examples for android.app ProgressDialog setMessage

Introduction

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

Prototype

@Override
    public void setMessage(CharSequence message) 

Source Link

Usage

From source file:com.imalu.alyou.activity.LoginActivity.java

/**
 * //from  w w  w  .  j ava  2s .  c o m
 * 
 * @param view
 */
public void login(View view) {
    if (!CommonUtils.isNetWorkConnected(this)) {
        Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;
    }

    final String username = usernameEditText.getText().toString();
    final String password = passwordEditText.getText().toString();
    //AlUApplication.currentUserNick = usernameEditText.getText().toString();

    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) {

        progressShow = true;
        final ProgressDialog pd = new ProgressDialog(LoginActivity.this);
        pd.setCanceledOnTouchOutside(false);
        pd.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                progressShow = false;
            }
        });
        pd.setMessage("...");
        pd.show();

        LoginRequest loginReq = new LoginRequest();
        loginReq.setUsername(username);
        loginReq.setPassword(password);

        NetManager.execute(NetManager.LOGIN_REQUEST_OPERATION, loginReq, new JsonHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {

                try {

                    pd.dismiss();
                    Log.e("login_check", " response:" + response.toString());

                    UserInfo userInfo = new UserInfo();
                    userInfo.setJsonObject(response);

                    AlUApplication.getMyInfo().setPhoneNum(username);
                    AlUApplication.getMyInfo().setPassword(password);
                    AlUApplication.getMyInfo().setHxname(userInfo.getHXName());
                    AlUApplication.getMyInfo().setId(userInfo.getID());
                    AlUApplication.getMyInfo().setUsername(userInfo.getUserName());
                    AlUApplication.getMyInfo().setKey(userInfo.getKey());
                    AlUApplication.getMyInfo().setJifen(userInfo.getJifen());
                    AlUApplication.getMyInfo().setAge(userInfo.getAge());
                    AlUApplication.getMyInfo().setLocus(userInfo.getLocus());
                    AlUApplication.getMyInfo().setRealname(userInfo.getRealName());
                    AlUApplication.getMyInfo().setSex(userInfo.getSex());
                    AlUApplication.getMyInfo().setSocietykey(userInfo.getSocietyKey());
                    AlUApplication.getMyInfo().setJiarugonghuikey(userInfo.getJiaruGonghuiKey());
                    AlUApplication.getMyInfo().setSocietyName(userInfo.getSocietyName());

                    PersonalInfoResponse personal = new PersonalInfoResponse();
                    personal.setJsonObject(response);
                    AlUApplication.getUserfans().setId(personal.getId());
                    AlUApplication.getUserfans().setJifen(personal.getJifen());
                    AlUApplication.getUserfans().setUserName(personal.getUserName());
                    AlUApplication.getUserfans().setSocietyName(personal.getSocietyName());

                    // ?????
                    AlUApplication.getInstance().setUserName(username);
                    AlUApplication.getInstance().setPassword(password);

                    User user = new User();
                    user.setId((long) userInfo.getID());
                    user.setUsername(username);
                    user.setPassword(password);
                    user.setChatuser(userInfo.getHXName());
                    saveUserToDB(user);

                    /*
                    runOnUiThread(new Runnable() {
                       public void run() {
                          pd.setMessage("...");
                       }
                    });
                    */

                    EMChatManager.getInstance().login(userInfo.getHXName(), userInfo.getHXPwd(),
                            new EMCallBack() {

                                @Override
                                public void onSuccess() {
                                    EMChatManager.getInstance().loadAllConversations();
                                }

                                @Override
                                public void onProgress(int progress, String status) {
                                    // TODO Auto-generated method stub
                                }

                                @Override
                                public void onError(int code, String message) {
                                    // TODO Auto-generated method stub
                                }
                            });

                    // ** ?logout??
                    // ** manually load all local groups and
                    // conversations in case we are auto login
                    //EMGroupManager.getInstance().loadAllGroups();

                    // demo??????username??
                    /*List<String> usernames = EMContactManager.getInstance().getContactUserNames();
                    EMLog.d("roster", "contacts size: " + usernames.size());
                            
                    for (String username : usernames) {
                       User user = new User();
                       user.setUsername(username);
                       setUserHearder(username, user);
                       userlist.put(username, user);
                    }*/
                    /*Map<String, User> userlist = new HashMap<String, User>();
                    // user""
                    User newFriends = new User();
                    newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME);
                    newFriends.setNick("");
                    newFriends.setHeader("");
                    userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends);
                    // "?"
                    User groupUser = new User();
                    groupUser.setUsername(Constant.GROUP_USERNAME);
                    groupUser.setNick("?");
                    groupUser.setHeader("");
                    userlist.put(Constant.GROUP_USERNAME, groupUser);*/

                    // 
                    //AlUApplication.getInstance().setContactList(userlist);
                    // db
                    //UserDao dao = new UserDao(LoginActivity.this);
                    //List<User> users = new ArrayList<User>(userlist.values());
                    //dao.saveContactList(users);

                    // ??(??groupidgroupname????members),sdkdb
                    //EMGroupManager.getInstance().getGroupsFromServer();*/
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //?nickname ios?nick
                //boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(AlUApplication.currentUserNick);
                //if (!updatenick) {
                //   EMLog.e("LoginActivity", "update current user nick fail");
                //}

                //if (!LoginActivity.this.isFinishing())
                //pd.dismiss();
                // ?
                startActivity(new Intent(LoginActivity.this, MainActivity.class));
                finish();
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, final String responseString,
                    Throwable throwable) {
                if (!progressShow) {
                    return;
                }
                pd.dismiss();
                runOnUiThread(new Runnable() {
                    public void run() {
                        //pd.dismiss();
                        //Toast.makeText(getApplicationContext(), ": " + responseString, 0).show();

                    }
                });
            }
        });
    }
}

From source file:com.app.uafeed.activity.EditFeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();// w  w  w .  ja  v a  2s  .  c  o m
        return true;
    case R.id.menu_add_filter: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null);

        new AlertDialog.Builder(this) //
                .setTitle(R.string.filter_add_title) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText()
                                .toString();
                        if (filterText.length() != 0) {
                            String feedId = getIntent().getData().getLastPathSegment();

                            ContentValues values = new ContentValues();
                            values.put(FilterColumns.FILTER_TEXT, filterText);
                            values.put(FilterColumns.IS_REGEX,
                                    ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked());
                            values.put(FilterColumns.IS_APPLIED_TO_TITLE,
                                    ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked());

                            ContentResolver cr = getContentResolver();
                            cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values);
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                }).show();
        return true;
    }
    case R.id.menu_search_feed: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null);
        final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
        if (!mUrlEditText.getText().toString().startsWith(Constants.HTTP_SCHEME)
                && !mUrlEditText.getText().toString().startsWith(Constants.HTTPS_SCHEME)) {
            searchText.setText(mUrlEditText.getText());
        }
        final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

        new AlertDialog.Builder(EditFeedActivity.this) //
                .setIcon(R.drawable.action_search) //
                .setTitle(R.string.feed_search) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        if (searchText.getText().length() > 0) {
                            String tmp = searchText.getText().toString();
                            try {
                                tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                            } catch (UnsupportedEncodingException ignored) {
                            }
                            final String text = tmp;

                            switch (radioGroup.getCheckedRadioButtonId()) {
                            case R.id.byWebSearch:
                                final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
                                pd.setMessage(getString(R.string.loading));
                                pd.setCancelable(true);
                                pd.setIndeterminate(true);
                                pd.show();

                                getLoaderManager().restartLoader(1, null,
                                        new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                                            @Override
                                            public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(
                                                    int id, Bundle args) {
                                                return new GetFeedSearchResultsLoader(EditFeedActivity.this,
                                                        text);
                                            }

                                            @Override
                                            public void onLoadFinished(
                                                    Loader<ArrayList<HashMap<String, String>>> loader,
                                                    final ArrayList<HashMap<String, String>> data) {
                                                pd.cancel();

                                                if (data == null) {
                                                    Toast.makeText(EditFeedActivity.this, R.string.error,
                                                            Toast.LENGTH_SHORT).show();
                                                } else if (data.isEmpty()) {
                                                    Toast.makeText(EditFeedActivity.this, R.string.no_result,
                                                            Toast.LENGTH_SHORT).show();
                                                } else {
                                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                                            EditFeedActivity.this);
                                                    builder.setTitle(R.string.feed_search);

                                                    // create the grid item mapping
                                                    String[] from = new String[] { FEED_SEARCH_TITLE,
                                                            FEED_SEARCH_DESC };
                                                    int[] to = new int[] { android.R.id.text1,
                                                            android.R.id.text2 };

                                                    // fill in the grid_item layout
                                                    SimpleAdapter adapter = new SimpleAdapter(
                                                            EditFeedActivity.this, data,
                                                            R.layout.item_search_result, from, to);
                                                    builder.setAdapter(adapter,
                                                            new DialogInterface.OnClickListener() {
                                                                @Override
                                                                public void onClick(DialogInterface dialog,
                                                                        int which) {
                                                                    mNameEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_TITLE));
                                                                    mUrlEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_URL));
                                                                }
                                                            });
                                                    builder.show();
                                                }
                                            }

                                            @Override
                                            public void onLoaderReset(
                                                    Loader<ArrayList<HashMap<String, String>>> loader) {
                                            }
                                        });
                                break;

                            case R.id.byTopic:
                                mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                        + "&start=1&length=10&l=en&src=news&f=rss");
                                break;

                            case R.id.byYoutube:
                                mUrlEditText.setText("http://www.youtube.com/rss/user/"
                                        + text.replaceAll("\\+", "") + "/videos.rss");
                                break;
                            }
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:nl.eduvpn.app.fragment.HomeFragment.java

/**
 * Now that we have the key pair, we can download the profile.
 *
 * @param instance      The API instance definition.
 * @param discoveredAPI The discovered API URLs.
 * @param savedKeyPair  The private key and certificate used to generate the profile.
 * @param profile       The profile to create.
 * @param dialog        Loading dialog which should be dismissed when finished.
 *///from w  w  w .  j av a  2  s  .  c om
private void _downloadProfileWithKeyPair(final Instance instance, DiscoveredAPI discoveredAPI,
        final SavedKeyPair savedKeyPair, final Profile profile, final AuthState authState,
        final ProgressDialog dialog) {
    dialog.setMessage(getString(R.string.vpn_profile_download_message));
    String requestData = "?profile_id=" + profile.getProfileId();
    _apiService.getString(discoveredAPI.getProfileConfigEndpoint() + requestData, authState,
            new APIService.Callback<String>() {
                @Override
                public void onSuccess(String vpnConfig) {
                    // The downloaded profile misses the <cert> and <key> fields. We will insert that via the saved key pair.
                    String configName = FormattingUtils.formatProfileName(getContext(), instance, profile);
                    VpnProfile vpnProfile = _vpnService.importConfig(vpnConfig, configName, savedKeyPair);
                    if (vpnProfile != null && getActivity() != null) {
                        // Cache the profile
                        SavedProfile savedProfile = new SavedProfile(instance, profile,
                                vpnProfile.getUUIDString());
                        _historyService.cacheSavedProfile(savedProfile);
                        // Connect with the profile
                        dialog.dismiss();
                        _vpnService.connect(getActivity(), vpnProfile);
                        ((MainActivity) getActivity()).openFragment(new ConnectionStatusFragment(), false);
                    } else {
                        dialog.dismiss();
                        _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title,
                                R.string.error_importing_profile);
                    }
                }

                @Override
                public void onError(String errorMessage) {
                    dialog.dismiss();
                    _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title,
                            getString(R.string.error_fetching_profile, errorMessage));
                    Log.e(TAG, "Error fetching profile: " + errorMessage);
                }
            });
}

From source file:org.otempo.view.StationActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;// w  ww . j  av a  2  s.  com
    switch (id) {
    case DIALOG_LOADING_ID: {
        // No usar nunca esta forma, peta en 1.5, porque el show se hace dos veces:
        //dialog = ProgressDialog.show(this, "", getString(R.string.loading_data), true);
        ProgressDialog progress = new ProgressDialog(this);
        progress.setMessage(getString(R.string.loading_data));
        progress.setIndeterminate(true);
        dialog = progress;
        _dialogLoadingShown = true;
        break;
    }
    case DIALOG_PREDICTION_EXPLAIN_ID: {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getString(R.string.predicted_time_explain)).setCancelable(false)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        dialog = builder.create();
        break;
    }
    default:
        if (id >= DIALOG_DAY_COMMENT_MASK) {
            Station station = _stationManager.getStation();
            if (station != null) {
                int day = id - DIALOG_DAY_COMMENT_MASK - station.getId() * MAX_PREDICTED_DAYS;
                if (day >= station.getPredictions().size()) {
                    // Avoid overflow if tapping past the last prediction.
                    return null;
                }
                StationPrediction prediction = station.getPredictions().get(day);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                Calendar predictionDate = prediction.getDate();
                String header = "";
                if (predictionDate != null) {
                    header = DateUtils.weekDayFormat.format(predictionDate.getTime());
                }
                builder.setMessage(header + ":\n\n" + prediction.createDescription(this)).setCancelable(false)
                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                return builder.create();
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setMessage(getString(R.string.loading_data)).setCancelable(false)
                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                return builder.create();
            }
        }
        return super.onCreateDialog(id);
    }
    return dialog;
}

From source file:cn.ucai.chatuidemo.activity.ContactlistFragment.java

/**
 * user???//from www. j  a  v  a  2 s.c  o  m
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_LONG).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_LONG).show();
                    }
                });
            }
        }
    }).start();

}

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

public void addToList(final String item_id) {
    final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
    myOtherProgressDialog.setTitle("Please Wait ...");
    myOtherProgressDialog.setMessage("Adding item to study goal ...");
    myOtherProgressDialog.setIndeterminate(true);
    myOtherProgressDialog.setCancelable(true);

    final Thread add = new Thread() {
        public void run() {
            ItemActivity.add_item_result = new AddItemResult(
                    Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, null));

            myOtherProgressDialog.dismiss();
            ItemActivity.this.runOnUiThread(new Thread() {
                public void run() {
                    final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create();
                    dialog.setTitle(ItemActivity.add_item_result.getTitle());
                    dialog.setMessage(ItemActivity.add_item_result.getMessage());
                    ItemActivity.add_item_result = null;
                    dialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                        }/*from w  w w  .j ava 2  s  . com*/
                    });

                    dialog.show();
                }
            });

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

From source file:com.eleybourn.bookcatalogue.utils.SimpleTaskQueueProgressFragment.java

/**
 * Create the underlying dialog// www. j av a2  s  .c  om
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(false);

    int msg = getArguments().getInt("title");
    if (msg != 0)
        dialog.setMessage(getActivity().getString(msg));
    final boolean isIndet = getArguments().getBoolean("isIndeterminate");
    dialog.setIndeterminate(isIndet);
    if (isIndet) {
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    } else {
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    }

    // We can't use "this.requestUpdateProgress()" because getDialog() will still return null
    if (!isIndet) {
        dialog.setMax(mMax);
        dialog.setProgress(mProgress);
        if (mMessage != null)
            dialog.setMessage(mMessage);
        setDialogNumberFormat(dialog);
    }

    return dialog;
}

From source file:net.sylvek.sharemyposition.ShareMyPosition.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    default://www  .jav a 2  s.  c om
        return super.onCreateDialog(id);
    case MAP_DLG:
        final View sharedMapView = LayoutInflater.from(this).inflate(R.layout.sharedmap, null);
        final FrameLayout map = (FrameLayout) sharedMapView.findViewById(R.id.sharedmap);
        map.addView(this.sharedMap);
        final CheckBox latlonAddress = (CheckBox) sharedMapView.findViewById(R.id.add_lat_lon_location);
        final CheckBox geocodeAddress = (CheckBox) sharedMapView.findViewById(R.id.add_address_location);
        final RadioButton nourl = (RadioButton) sharedMapView.findViewById(R.id.add_no_url_location);
        final RadioButton url = (RadioButton) sharedMapView.findViewById(R.id.add_url_location);
        final RadioButton gmap = (RadioButton) sharedMapView.findViewById(R.id.add_native_location);
        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
        final ToggleButton track = (ToggleButton) sharedMapView.findViewById(R.id.add_track_location);

        latlonAddress.setChecked(pref.getBoolean(PREF_LAT_LON_CHECKED, true));
        geocodeAddress.setChecked(pref.getBoolean(PREF_ADDRESS_CHECKED, true));
        final boolean isUrl = pref.getBoolean(PREF_URL_CHECKED, true);
        final boolean isGmap = pref.getBoolean(PREF_GMAP_CHECKED, false);
        url.setChecked(isUrl);
        gmap.setChecked(isGmap);
        nourl.setChecked(!isUrl && !isGmap);
        body.setText(pref.getString(PREF_BODY_DEFAULT, getString(R.string.body)));
        track.setChecked(pref.getBoolean(PREF_TRACK_CHECKED, false));

        if (track.isChecked()) {
            latlonAddress.setEnabled(false);
            latlonAddress.setChecked(false);
            geocodeAddress.setEnabled(false);
            geocodeAddress.setChecked(false);
            url.setEnabled(false);
            url.setChecked(true);
            gmap.setEnabled(false);
            gmap.setChecked(false);
            nourl.setEnabled(false);
            nourl.setChecked(false);
        }

        track.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                latlonAddress.setEnabled(!isChecked);
                latlonAddress.setChecked(!isChecked);
                geocodeAddress.setEnabled(!isChecked);
                geocodeAddress.setChecked(!isChecked);
                url.setEnabled(!isChecked);
                url.setChecked(true);
                gmap.setEnabled(!isChecked);
                gmap.setChecked(!isChecked);
                nourl.setEnabled(!isChecked);
                nourl.setChecked(!isChecked);
            }
        });

        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setView(sharedMapView)
                .setOnCancelListener(new OnCancelListener() {

                    @Override
                    public void onCancel(DialogInterface arg0) {
                        finish();
                    }
                }).setNeutralButton(R.string.options, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        /* needed to display neutral button */
                    }
                }).setPositiveButton(R.string.share_it, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        final boolean isLatLong = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_lat_lon_location)).isChecked();
                        final boolean isGeocodeAddress = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_address_location)).isChecked();
                        final boolean isUrl = ((RadioButton) sharedMapView.findViewById(R.id.add_url_location))
                                .isChecked();
                        final boolean isGmap = ((RadioButton) sharedMapView
                                .findViewById(R.id.add_native_location)).isChecked();
                        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
                        final boolean isTracked = ((ToggleButton) sharedMapView
                                .findViewById(R.id.add_track_location)).isChecked();
                        final String uuid = UUID.randomUUID().toString();

                        pref.edit().putBoolean(PREF_LAT_LON_CHECKED, isLatLong)
                                .putBoolean(PREF_ADDRESS_CHECKED, isGeocodeAddress)
                                .putBoolean(PREF_URL_CHECKED, isUrl).putBoolean(PREF_GMAP_CHECKED, isGmap)
                                .putString(PREF_BODY_DEFAULT, body.getText().toString())
                                .putBoolean(PREF_TRACK_CHECKED, isTracked).commit();

                        final Intent t = new Intent(Intent.ACTION_SEND);
                        t.setType("text/plain");
                        t.addCategory(Intent.CATEGORY_DEFAULT);
                        final Intent share = Intent.createChooser(t, getString(R.string.app_name));
                        final GeoPoint p = sharedMap.getMapCenter();

                        final String text = body.getText().toString();
                        share(p.getLatitude(), p.getLongitude(), t, share, text, isGeocodeAddress, isUrl,
                                isGmap, isLatLong, isTracked, uuid);
                    }
                }).create();
    case PROGRESS_DLG:
        final ProgressDialog dlg = new ProgressDialog(this);
        dlg.setTitle(getText(R.string.app_name));
        dlg.setMessage(getText(R.string.progression_desc));
        dlg.setIndeterminate(true);
        dlg.setCancelable(true);
        dlg.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        return dlg;
    case PROVIDERS_DLG:
        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setCancelable(false)
                .setIcon(android.R.drawable.ic_menu_help).setMessage(R.string.providers_needed)
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }

                }).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent gpsProperty = new Intent(
                                android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(gpsProperty);
                    }
                }).create();
    }
}

From source file:org.namelessrom.devicecontrol.appmanager.AppDetailsActivity.java

private void uninstall() {
    // try via native package manager api
    AppHelper.uninstallPackage(mPm, mAppItem.getPackageName());

    // build our command
    final StringBuilder sb = new StringBuilder();

    sb.append(String.format("pm uninstall %s;", mAppItem.getPackageName()));

    if (mAppItem.isSystemApp()) {
        sb.append("busybox mount -o rw,remount /system;");
    }/*from  w  w  w  .j a  v  a2s. c o m*/

    sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().publicSourceDir));
    sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().sourceDir));
    sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().dataDir));

    if (mAppItem.isSystemApp()) {
        sb.append("busybox mount -o ro,remount /system;");
    }

    final String cmd = sb.toString();
    Logger.v(this, cmd);

    // create the dialog (will not be shown for a long amount of time though)
    final ProgressDialog dialog;
    dialog = new ProgressDialog(this);
    dialog.setTitle(R.string.uninstalling);
    dialog.setMessage(getString(R.string.applying_wait));
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setCancelable(false);

    new AsyncTask<Void, Void, Void>() {

        @Override
        protected void onPreExecute() {
            dialog.show();
        }

        @Override
        protected Void doInBackground(Void... voids) {
            Utils.runRootCommand(cmd, true);
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            dialog.dismiss();
            Toast.makeText(AppDetailsActivity.this, getString(R.string.uninstall_success, mAppItem.getLabel()),
                    Toast.LENGTH_SHORT).show();
            mAppItem = null;
            finish();

        }
    }.execute();
}

From source file:cn.ucai.foraging.activity.ContactlistFragment.java

/**
 * user???/*from  www.  j a  v  a2  s  .  com*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(cn.ucai.foraging.R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(cn.ucai.foraging.R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(cn.ucai.foraging.R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, 0).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, 0).show();
                    }
                });
            }
        }
    }).start();

}