[android-developers] BadTokenException + BACK

2011-01-14 Thread Amico
I know this topic was asked trillions of times throughout the web, but
there is no one place answering it.

in my application, I have a welcome screen. when I run the program end-
to-end everything is just fine - open/close activities and show
dialogs of all sorts.
but, when I reach the welcome screen and from there pressing the BACK
button - everything becomes messy:
1) the dialog i want to show cause BadTokenException (i'm using this
and not getApplicationContext() ).

2) I tried use try/catch to catch the exception - and it really passed
the showDialog line. but then, in the 2nd. run, when reaching a
showDialog expression, it throws IllegalStateException:
View.com.android.internal.policy.impl.PhoneWindow$DecorView@44a59830
has already been added to the window manager.

moreover, I understand that pressing HOME causes the onPause in the
activity, while BACK causes onDestroy, but what goes wrong ??

i'm trying to fix that issue for more than a week, but with no
success. any ideas ?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] showDialog's BadTokenException + BACK button

2011-01-14 Thread Amico
hey,

I know you've all had enough with this exception. there are trillions
of threads in many forums about this exception (yes, 'm using "this"
and not getApplicationContext() in showDialog) - but I couldnt find a
single solution for that.
if I run my code everything is OK. once I press the "back" button, as
far as I nderstood it goes through the entire activity destruction
(onPause-->onStop-->onDestroy). when I start the application again,
when I want to show a dialog using showDialog, I get the
BadTokedException.

I can post some of the code if nessacery, but its more a general
problem.
10x, for any reply.

Amir

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] isFinishing() & BadTokenException - very weird !!

2011-01-14 Thread Amico
hey,

I have a very weird behaviour, which I cant find its cause.
the last thing I do on onCreate() is to call a certain method.
in that method i use
**progressDialog = ProgressDialog.show(this, null, "Registering with
Moish'd! server", true, false);**.
on the first run i get BadTokenException: Unable to add window on the
_progressDialog_ line.
the second run it passes it.
I read in forums that if the activity is in the middle of "finish"
process than it might cause such an excetion.
after a long debugging tests, i tried asking for isFinishing().
something odd accoured - before calling the method, **isFinishing()
returns false**.in the first line of the method I ask again and now
**isFinishing() returns true**.
how can it be ?!?  in the last line before entering a method its not
"finishing" and in the first line of the method its suddenly
"finishing", when NOTHING is happening in between (certainly not
calling finish()).  anyone ?!?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en