Preventing the back button from cancelling a DialogFragment

How about using setCancelable? Did you try it? From the Docs: Control whether the shown Dialog is cancelable. Use this instead of directly calling Dialog.setCancelable(boolean), because DialogFragment needs to change its behavior based on this For custom DialogFragment Add isCancelable = false at onCreateDialog

Android: “BadTokenException: Unable to add window; is your activity running?” at showing dialog in PreferenceActivity

I had a very similar issue (which landed me here) and found a very simple fix for it. While my code is different, it should be easy to adapt. Here is my fix: public void showBox() { mActive = true; if (! ((Activity) mContext).isFinishing()) { mDialogBox.show(); } } So, in the sample code in the … Read more

Add a Progress Bar in WebView

I have added few lines in your code and now its working fine with progress bar. getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.main ); // Makes Progress bar Visible getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); webview = (WebView) findViewById(R.id.webview); webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { //Make the bar disappear after URL is loaded, and changes string to Loading… setTitle(“Loading…”); … Read more

ProgressDialog in AsyncTask

/** * this class performs all the work, shows dialog before the work and dismiss it after */ public class ProgressTask extends AsyncTask<String, Void, Boolean> { public ProgressTask(ListActivity activity) { this.activity = activity; dialog = new ProgressDialog(activity); } /** progress dialog to show user that the backup is processing. */ private ProgressDialog dialog; /** application … Read more

Can’t create handler inside thread that has not called Looper.prepare() inside AsyncTask for ProgressDialog

The method show() must be called from the User-Interface (UI) thread, while doInBackground() runs on different thread which is the main reason why AsyncTask was designed. You have to call show() either in onProgressUpdate() or in onPostExecute(). For example: class ExampleTask extends AsyncTask<String, String, String> { // Your onPreExecute method. @Override protected String doInBackground(String… params) … Read more

Show ProgressDialog Android

Declare your progress dialog: ProgressDialog progress; When you’re ready to start the progress dialog: progress = ProgressDialog.show(this, “dialog title”, “dialog message”, true); and to make it go away when you’re done: progress.dismiss(); Here’s a little thread example for you: // Note: declare ProgressDialog progress as a field in your class. progress = ProgressDialog.show(this, “dialog title”, … Read more

Android Fragments. Retaining an AsyncTask during screen rotation or configuration change

Fragments can actually make this a lot easier. Just use the method Fragment.setRetainInstance(boolean) to have your fragment instance retained across configuration changes. Note that this is the recommended replacement for Activity.onRetainnonConfigurationInstance() in the docs. If for some reason you really don’t want to use a retained fragment, there are other approaches you can take. Note … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)