Example usage for android.app ProgressDialog dismiss

List of usage examples for android.app ProgressDialog dismiss

Introduction

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

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:net.kazzz.NFCTagReader.java

public void onClick(final View v) {
    try {//ww w  .  j  ava2s . com
        final int id = v.getId();

        final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setIndeterminate(true);

        AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
            @Override
            protected void onPreExecute() {
                switch (id) {
                case R.id.btn_read:
                    dialog.setMessage("?????...");
                    break;
                case R.id.btn_write:
                    dialog.setMessage("???????...");
                    break;
                case R.id.btn_hitory:
                    dialog.setMessage("????...");
                    break;
                }
                dialog.show();
            }

            @Override
            protected String doInBackground(Void... arg0) {
                switch (id) {
                case R.id.btn_read:
                    try {
                        return mLastFragment.dumpTagData();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                case R.id.btn_write:
                    try {
                        Intent intent = new Intent(NFCTagReader.this, NFCTagWriter.class);
                        intent.putExtra("nfcTag", mLastFragment.getNfcTag());
                        startActivity(intent);
                        return "";
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                case R.id.btn_hitory:
                    try {
                        if (mLastFragment != null && mLastFragment instanceof NfcFeliCaTagFragment) {
                            NfcFeliCaTagFragment nfcf = (NfcFeliCaTagFragment) mLastFragment;
                            return nfcf.dumpFeliCaHistoryData();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                default:
                    break;
                }
                return "";
            }

            /* (non-Javadoc)
             * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
             */
            @Override
            protected void onPostExecute(String result) {
                dialog.dismiss();
                TextView tv_tag = (TextView) findViewById(R.id.result_tv);
                if (result != null && result.length() > 0)
                    tv_tag.setText(result);
            }
        };

        task.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.nttec.everychan.chans.ponyach.PonyachModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    final Context context = preferenceGroup.getContext();
    ListPreference captchaLevel = new LazyPreferences.ListPreference(context);
    captchaLevel.setTitle(R.string.ponyach_prefs_captcha);
    captchaLevel.setDialogTitle(R.string.ponyach_prefs_captcha);
    captchaLevel.setKey(getSharedKey(PREF_KEY_CAPTCHA_LEVEL));
    captchaLevel.setEntryValues(new String[] { "3", "2", "1" });
    captchaLevel.setEntries(new String[] { "Easy", "Easy++", "Medium" });
    captchaLevel.setDefaultValue("1");
    preferenceGroup.addPreference(captchaLevel);

    EditTextPreference passcodePref = new EditTextPreference(context);
    passcodePref.setTitle(R.string.ponyach_prefs_passcode);
    passcodePref.setDialogTitle(R.string.ponyach_prefs_passcode);
    passcodePref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(6) });
    passcodePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override/*from  w w  w  . j a v a2s . c  om*/
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String newPasscode = (String) newValue;
            final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask();
            final ProgressDialog passAuthProgressDialog = new ProgressDialog(context);
            passAuthProgressDialog.setMessage("Logging in");
            passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    passAuthTask.cancel();
                }
            });
            passAuthProgressDialog.setCanceledOnTouchOutside(false);
            passAuthProgressDialog.show();
            Async.runAsync(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (passAuthTask.isCancelled())
                            return;
                        String url = getUsingUrl() + "passcode.php";
                        List<BasicNameValuePair> pairs = Collections
                                .singletonList(new BasicNameValuePair("passcode_just_set", newPasscode));
                        HttpRequestModel request = HttpRequestModel.builder()
                                .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build();
                        HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, null,
                                passAuthTask, false);
                        savePhpCookies();
                    } catch (final Exception e) {
                        if (context instanceof Activity) {
                            ((Activity) context).runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String message = e.getMessage() == null
                                            ? resources.getString(R.string.error_unknown)
                                            : e.getMessage();
                                    Toast.makeText(context, message, Toast.LENGTH_LONG).show();
                                }
                            });
                        }
                    } finally {
                        passAuthProgressDialog.dismiss();
                    }
                }
            });
            return false;
        }
    });
    preferenceGroup.addPreference(passcodePref);

    ListPreference domainPref = new LazyPreferences.ListPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.setEntryValues(DOMAINS);
    domainPref.setEntries(DOMAINS);
    domainPref.setDefaultValue(DEFAULT_DOMAIN);
    domainPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            loadPhpCookies((String) newValue);
            return true;
        }
    });
    preferenceGroup.addPreference(domainPref);

    addHttpsPreference(preferenceGroup, useHttpsDefaultValue());
    addProxyPreferences(preferenceGroup);
    captchaLevel.setSummary(captchaLevel.getEntry());
    domainPref.setSummary(domainPref.getEntry());
}

From source file:com.cuddlesoft.nori.APISettingsActivity.java

@Override
public void editService(final long rowId, final String name, final String url, final String username,
        final String passphrase) {
    // Show progress dialog during the service type detection process.
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);//ww w  . j  av a2s .  c  o  m
    dialog.setCancelable(false);
    dialog.setMessage(getString(R.string.dialog_message_detectingApiType));
    dialog.show();

    // Register broadcast receiver to get results from the background service type detection service.
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // Get result code from received intent.
            int resultCode = intent.getIntExtra(ServiceTypeDetectionService.RESULT_CODE, -1);
            if (resultCode == ServiceTypeDetectionService.RESULT_OK) {
                // Add a new service to the database on a background thread.
                // This is so database I/O doesn't block the UI thread.
                SearchClient.Settings.APIType apiType = SearchClient.Settings.APIType.values()[intent
                        .getIntExtra(ServiceTypeDetectionService.API_TYPE, 0)];
                final SearchClient.Settings settings = new SearchClient.Settings(apiType, name, url, username,
                        passphrase);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        APISettingsDatabase database = new APISettingsDatabase(APISettingsActivity.this);
                        if (rowId == ROW_ID_INSERT) {
                            database.insert(settings);
                        } else {
                            database.update(rowId, settings);
                        }
                        database.close();
                    }
                }).run();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_INVALID_URL) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_serviceUriInvalid,
                        Toast.LENGTH_LONG).show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NETWORK) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noNetwork, Toast.LENGTH_LONG)
                        .show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NO_API) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noServiceAtGivenUri,
                        Toast.LENGTH_LONG).show();
            }

            // Unregister the broadcast receiver.
            unregisterReceiver(this);
            // Dismiss progress dialog.
            dialog.dismiss();
        }
    }, new IntentFilter(ServiceTypeDetectionService.ACTION_DONE));

    // Start the background service type detection service.
    Intent serviceIntent = new Intent(this, ServiceTypeDetectionService.class);
    serviceIntent.putExtra(ServiceTypeDetectionService.ENDPOINT_URL, url);
    startService(serviceIntent);
}

From source file:io.github.tjg1.nori.APISettingsActivity.java

@Override
public void editService(final long rowId, final String name, final String url, final String username,
        final String passphrase) {
    // Show progress dialog during the service type detection process.
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);//from w  w  w.j  a  va 2 s . c o m
    dialog.setCancelable(false);
    dialog.setMessage(getString(R.string.dialog_message_detectingApiType));
    dialog.show();

    // Register broadcast receiver to get results from the background service type detection service.
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // Get result code from received intent.
            int resultCode = intent.getIntExtra(ServiceTypeDetectionService.RESULT_CODE, -1);
            if (resultCode == ServiceTypeDetectionService.RESULT_OK) {
                // Add a new service to the database on a background thread.
                // This is so database I/O doesn't block the UI thread.
                SearchClient.Settings.APIType apiType = SearchClient.Settings.APIType.values()[intent
                        .getIntExtra(ServiceTypeDetectionService.API_TYPE, 0)];
                final SearchClient.Settings settings = new SearchClient.Settings(apiType, name, url, username,
                        passphrase);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        APISettingsDatabase database = new APISettingsDatabase(APISettingsActivity.this);
                        if (rowId == ROW_ID_INSERT) {
                            database.insert(settings);
                        } else {
                            database.update(rowId, settings);
                        }
                        database.close();
                    }
                }).start();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_INVALID_URL) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_serviceUriInvalid,
                        Toast.LENGTH_LONG).show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NETWORK) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noNetwork, Toast.LENGTH_LONG)
                        .show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NO_API) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noServiceAtGivenUri,
                        Toast.LENGTH_LONG).show();
            }

            // Unregister the broadcast receiver.
            unregisterReceiver(this);
            // Dismiss progress dialog.
            dialog.dismiss();
        }
    }, new IntentFilter(ServiceTypeDetectionService.ACTION_DONE));

    // Start the background service type detection service.
    Intent serviceIntent = new Intent(this, ServiceTypeDetectionService.class);
    serviceIntent.putExtra(ServiceTypeDetectionService.ENDPOINT_URL, url);
    startService(serviceIntent);
}

From source file:gr.scify.newsum.ui.ViewActivity.java

@Override
public void onGesturePerformed(GestureOverlayView overlay, final Gesture gesture) {
    // Get the Topic IDs per Category. Null means that all User Sources are
    // accepted/* w  w  w  .ja  v a  2s . com*/
    // User Sources is a separator delimited string containing the URL feeds
    final ProgressDialog pd = ProgressDialog.show(ViewActivity.this, "",
            getResources().getText(R.string.wait_msg));
    new Thread(new Runnable() {

        @Override
        public void run() {

            final Spinner spinner = (Spinner) findViewById(R.id.spinner1);
            ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
            for (Prediction prediction : predictions) {
                if (prediction.score > 1.0) {
                    // track the swipe Action per category
                    if (getAnalyticsPref()) {
                        EasyTracker.getTracker().sendEvent(SWIPING_ACTION, "Normal View", Category, 0l);
                    }
                    if (prediction.name.contains("right")) {
                        if (spinner.getSelectedItemPosition() > 0) {
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    spinner.setSelection(spinner.getSelectedItemPosition() - 1, true);

                                };
                            });

                        }

                    } else {

                        if (spinner.getSelectedItemPosition() < saTopicIDsLength - 1) {
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    spinner.setSelection(spinner.getSelectedItemPosition() + 1, true);
                                };
                            });

                        }

                    }
                }
            }

            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    pd.dismiss();

                }
            });
        }
    }).start();
}

From source file:com.example.prasadnr.traquad.TraQuad.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tra_quad);
    ConnectivityManager connManager = (ConnectivityManager) getSystemService(TraQuad.CONNECTIVITY_SERVICE);
    NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    Builder alert = new AlertDialog.Builder(TraQuad.this);

    WifiManager managerWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    Method[] wmMethods = managerWifi.getClass().getDeclaredMethods();
    for (Method method : wmMethods) {
        if (method.getName().equals("isWifiApEnabled")) {

            try {
                isWifiAPenabled = (boolean) method.invoke(managerWifi);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();//from ww w  .j  ava  2s  . com
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }

    final ProgressDialog pDialog;
    MediaController mediaController = new MediaController(this);

    pDialog = new ProgressDialog(TraQuad.this);
    pDialog.setTitle("TraQuad app (Connecting...)");
    pDialog.setMessage("Buffering...Please wait...");
    pDialog.setCancelable(true);

    if (!isWifiAPenabled) {

        alert.setTitle("WiFi Hotspot Settings");
        alert.setMessage("Can you please connect WiFi-hotspot?");
        alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                irritation = true;
                startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
                pDialog.show();
            }
        });
        alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //Dismiss AlertDialog
                pDialog.show();
                Toast.makeText(getApplicationContext(), "Please connect your WiFi!", Toast.LENGTH_LONG).show();
            }
        });
        alert.setCancelable(false);
        AlertDialog alertDialog = alert.create();
        alertDialog.show();
    }

    WebView webView = (WebView) findViewById(R.id.webView);

    if (irritation == true | isWifiAPenabled) {
        pDialog.show();
    }

    mediaController.setAnchorView(webView);
    mediaController.setVisibility(View.GONE);

    extra = getIntent().getStringExtra("VideosId");
    webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);

    final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
    final String IPaddressNew = globalVariable.getIP();
    final String httpString = "http://";
    final String commandPort = String.valueOf(1500);
    final String streamPort = String.valueOf(8080);
    final String IPaddressStream = httpString + IPaddressNew + ":" + streamPort;
    final String IPaddressCommand = httpString + IPaddressNew + ":" + commandPort;
    TextView sendCharacter = (TextView) findViewById(R.id.sendCharacter);

    try {
        webView.loadUrl(IPaddressStream);
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), IPaddressNew + ":Error!", Toast.LENGTH_LONG).show();
    }

    webView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            pDialog.dismiss();
        }
    });

    final Button switchact = (Button) findViewById(R.id.btn2);
    switchact.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent act1 = new Intent(view.getContext(), Joypad.class);
            startActivity(act1);

        }
    });

    final Button hometraquad = (Button) findViewById(R.id.button5);

    hometraquad.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            Intent acthometraquad = new Intent(TraQuad.this, MainActivity.class);
            startActivity(acthometraquad);
        }
    });

}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * Apply or save iptable rules, showing a visual indication
 *///from   w w  w  .j a v a  2  s.  co m
private void applyOrSaveRules() {
    final Resources res = getResources();
    final boolean enabled = Api.isEnabled(this);
    final ProgressDialog progress = ProgressDialog.show(this, res.getString(R.string.working),
            res.getString(enabled ? R.string.applying_rules : R.string.saving_rules), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            int i;
            try {
                progress.dismiss();
            } catch (Exception ex) {
            }
            if (enabled) {
                Log.d(TAG, "Applying rules.");
                if (Api.hasRootAccess(MainActivity.this, true)
                        && Api.applyIptablesRules(MainActivity.this, true)) {
                    Toast.makeText(MainActivity.this, R.string.rules_applied, Toast.LENGTH_SHORT).show();
                    if (abs_menu != null) {
                        final MenuItem item_onoff = abs_menu.findItem(R.id.enableipv4);
                        final MenuItem item_apply = abs_menu.findItem(R.id.applyrules);
                        item_apply.setTitle(R.string.applyrules);
                        item_onoff.setChecked(true);
                    }
                    i = prefs.getInt("itemPosition", 0);
                    if (i == 0) {
                        saveDefaultProfile();
                    }
                    if (i == 1) {
                        saveProfile1();
                    }
                    if (i == 2) {
                        saveProfile2();
                    }
                    if (i == 3) {
                        saveProfile3();
                    }
                    if (i == 4) {
                        saveProfile4();
                    }
                    if (i == 5) {
                        saveProfile5();
                    }
                } else {
                    Log.d(TAG, "Failed - Disabling firewall.");
                    Api.setEnabled(MainActivity.this, false);
                    if (abs_menu != null) {
                        final MenuItem item_onoff = abs_menu.findItem(R.id.enableipv4);
                        final MenuItem item_apply = abs_menu.findItem(R.id.applyrules);
                        item_apply.setTitle(R.string.saverules);
                        item_onoff.setChecked(false);
                    }
                }

            }

            else {
                Log.d(TAG, "Saving rules.");
                Api.saveRules(MainActivity.this);
                Toast.makeText(MainActivity.this, R.string.rules_saved, Toast.LENGTH_SHORT).show();
                i = prefs.getInt("itemPosition", 0);
                if (i == 0) {
                    saveDefaultProfile();
                }
                if (i == 1) {
                    saveProfile1();
                }
                if (i == 2) {
                    saveProfile2();
                }
                if (i == 3) {
                    saveProfile3();
                }
                if (i == 4) {
                    saveProfile4();
                }
                if (i == 5) {
                    saveProfile5();
                }
            }
            MainActivity.this.dirty = false;
        }
    };
    handler.sendEmptyMessageDelayed(0, 100);
}

From source file:org.matrix.console.activity.SettingsActivity.java

private void saveChanges(final MXSession session) {
    LinearLayout linearLayout = mLinearLayoutByMatrixId.get(session.getCredentials().userId);

    final String nameFromForm = getEditedUserName(session);
    final ApiCallback<Void> changeCallback = UIUtils.buildOnChangeCallback(this);

    final MyUser myUser = session.getMyUser();
    final Button saveButton = (Button) linearLayout.findViewById(R.id.button_save);

    // disable the save button to avoid unexpected behaviour
    saveButton.setEnabled(false);//  w w  w . j  ava  2 s .  c  o  m

    if (UIUtils.hasFieldChanged(myUser.displayname, nameFromForm)) {
        myUser.updateDisplayName(nameFromForm, new SimpleApiCallback<Void>(changeCallback) {
            @Override
            public void onSuccess(Void info) {
                super.onSuccess(info);
                updateSaveButton(saveButton);
            }
        });
    }

    Uri newAvatarUri = mTmpThumbnailUriByMatrixId.get(session.getCredentials().userId);

    if (newAvatarUri != null) {
        Log.d(LOG_TAG, "Selected image to upload: " + newAvatarUri);
        ResourceUtils.Resource resource = ResourceUtils.openResource(this, newAvatarUri);
        if (resource == null) {
            Toast.makeText(SettingsActivity.this, getString(R.string.settings_failed_to_upload_avatar),
                    Toast.LENGTH_LONG).show();
            return;
        }

        final ProgressDialog progressDialog = ProgressDialog.show(this, null,
                getString(R.string.message_uploading), true);

        session.getContentManager().uploadContent(resource.contentStream, null, resource.mimeType, null,
                new ContentManager.UploadCallback() {

                    @Override
                    public void onUploadStart(String uploadId) {
                    }

                    @Override
                    public void onUploadProgress(String anUploadId, int percentageProgress) {
                        progressDialog.setMessage(
                                getString(R.string.message_uploading) + " (" + percentageProgress + "%)");
                    }

                    @Override
                    public void onUploadComplete(String anUploadId, ContentResponse uploadResponse,
                            final int serverResponseCode, String serverErrorMessage) {
                        if (uploadResponse == null) {
                            Toast.makeText(SettingsActivity.this,
                                    (null != serverErrorMessage) ? serverErrorMessage
                                            : getString(R.string.settings_failed_to_upload_avatar),
                                    Toast.LENGTH_LONG).show();
                        } else {
                            Log.d(LOG_TAG, "Uploaded to " + uploadResponse.contentUri);
                            myUser.updateAvatarUrl(uploadResponse.contentUri,
                                    new SimpleApiCallback<Void>(changeCallback) {
                                        @Override
                                        public void onSuccess(Void info) {
                                            super.onSuccess(info);
                                            // Reset this because its being set is how we know there's been a change
                                            mTmpThumbnailUriByMatrixId.remove(session.getCredentials().userId);
                                            updateSaveButton(saveButton);
                                        }
                                    });
                        }
                        progressDialog.dismiss();
                    }
                });
    }
}

From source file:com.easemob.chatui.activity.ContactlistFragment.java

/**
 * ?/*from w  w w.jav  a  2  s .c o m*/
 *
 * @param
 */

public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                /**?????*/
                HttpUtils httpUtils = new HttpUtils();
                MyRequestParams params = new MyRequestParams();
                params.addQueryStringParameter("userid",
                        BeewayApplication.getInstance().getmUserid(getActivity()));
                params.addQueryStringParameter("friendid", tobeDeleteUser.getUsername());
                //                        params.addBodyParameter("iden", iden);
                String url = params.myRequestParams(params);
                httpUtils.send(HttpRequest.HttpMethod.POST, UrlPools.DEL_FRIEND + "?" + url,
                        new RequestCallBack<String>() {

                            @Override
                            public void onSuccess(ResponseInfo<String> responseInfo) {
                                String result = responseInfo.result;
                                DelBean delBean = paraseDelData(result);
                                if (delBean.getStatus() == 1) {
                                    /**db??*/
                                    FriendDao friendDao = new FriendDao(getActivity());
                                    friendDao.deleteFriend(tobeDeleteUser.getUsername());
                                    Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT).show();

                                }
                            }

                            @Override
                            public void onFailure(HttpException e, String s) {
                                LogUtils.e(s);
                            }
                        });
                BeewayApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * If the applications are cached, just show them, otherwise load and show
 *///from w  w w .j  a va2 s . co m
public void showOrLoadApplications() {
    final Resources res = getResources();
    final String search = "";
    if (Api.applications == null) {
        // The applications are not cached.. so lets display the progress
        // dialog
        final ProgressDialog progress = ProgressDialog.show(this, res.getString(R.string.working),
                res.getString(R.string.reading_apps), true);
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                Api.getApps(MainActivity.this);
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                try {
                    progress.dismiss();
                } catch (Exception ex) {
                    Log.d("{AF} - error in showorloadapplications", ex.getMessage());
                }
                createListView(search);
            }
        }.execute();
    } else {
        // the applications are cached, just show the list
        createListView(search);
    }
}