Bolha, Thanks for responding.
Dialog is created using onCreateDialog and I am invoking it by
showDialog(int id)
Below is the code. When my PurchaseActivity starts I do not want the
dialog to go away until I get response from the server but clicking on
the search button removes it. For now I have created a customer
ProgressDialog class and eating the search button, which makes sure
dialog doesnt go, but there will be other scenarios like incoming call
which will remove the dialog
public abstract class MyBaseActivity extends Activity {
public static final int DIALOG_PROGRESS_SPINNER = 3;
Handler handler = new Handler();
ProgressDialog progressDialog;
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_PROGRESS_SPINNER:
progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage(getString(R.string.loading));
progressDialog.setCancelable(false);
return progressDialog;
}
return super.onCreateDialog(id);
}
}
public class PurchaseActivity extends MyBaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.purchase_screen);
//do other stuff
handler.post(new Runnable() {
@Override
public void run() {
showDialog(DIALOG_PROGRESS_SPINNER);
//call asynch thread to do some server work
which will call
listener in the same activity to dismiss dialog
}
});
}
}
On Feb 26, 4:08 am, Bolha <[email protected]> wrote:
> Amit,
>
> How are you creating the dialog? Sometimes, when creating a dialog
> outside the overriden method "onCreateDialog" (from Activity class),
> the dialog can have strange behaviors (mainly because it sometimes the
> dialog instance is lacking a reference to its parent). Can you post a
> piece of your source code?
>
> Thanks
>
> Bolha
>
> On 25 fev, 16:53, A R <[email protected]> wrote:
>
> > Hi,
>
> > I have an activity which starts with a progress bar and I do not want
> > the progress bar to go away until the processing is done, I have set
> > the dialog to be setCancelable(false) so now user cannot cancel it
> > with back but there are several other situations which hides the
> > dialog for eg pressing 'search'.
>
> > On clicking of 'search' button the search box and keyboard pops up,
> > back button hides it and shows my activity which is always in the
> > background but the dialog is gone.
>
> > I can disable the search button but ideally I would want dialog to
> > come back when the activity comes in foreground again. Any ideas how
> > to do it?
>
> > Regards,
> > Amit.
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en