Gracefully destroying Dialog box

by Neilz » Fri, 23 Oct 2009 20:11:55 GMT

Sponsored Links
 Hi. I have an activity which pops up a Dialog box, to get some text
input from the user. The problem arises when you switch orientation.
The Dialog disappears, so I have added code to set and check flags in
the savedInstanceState, meaning that the Dialog is displayed again in
these circumstances.

However, the dialog isn't being closed gracefully when the orientation
is switched. I get the following error:

10-23 12:53:54.385: ERROR/WindowManager(2852): Activity
com.bla.bla.Bla has leaked window$decorv...@435ceda0 that
was originally added here
10-23 12:53:54.385: ERROR/WindowManager(2852):
android.view.WindowLeaked: Activity com.bla.bla.Bla has leaked window$decorv...@435ceda0 that
was originally added here

I know when the window is going to be closed, but can't find a way of
closing it manually. I open it with;  ...but there
doesn't seem to be any corresponding alert.destroy() method or

Any ideas how I can manually close the dialog box without user input?

Gracefully destroying Dialog box

by Neilz » Sat, 24 Oct 2009 16:46:35 GMT

 Oh well. Maybe I should raise it as a bug, as this is a problem to me,
and it seems there should be a standard method to the effect of


Sponsored Links

Gracefully destroying Dialog box

by Lance Nanek » Sat, 24 Oct 2009 17:13:00 GMT

 You can close a dialog using its dismiss() method : #dismiss%28%29

You might want to consider having the activity manage restoring your
dialog for you as well: #onCreateDialog%28int%29


Other Threads

1. Does Android support any XML Database??

Hello all,

I need to use a XML Database in Android for my thesis.

Does Android support any XML Database??

Or can I install Oracle Berkeley DB XML into Android??

(Oracle Berkeley DB has a java edition, but it is not xml db.
And Oracle Berkeley DB XML is xml db, but it is written by C++.
can't I install Berkeley DB XML into linux on Android??)

Thanks in advance.


2. How to hand in a callback in AIDL?

I have found it convenient to make AIDL interfaces in pairs -- one for
how the client calls the server, and one by which a server can call
back into the client.  However, I find that the design of the Proxy/
Stub model (which I confess I don't fully grasp) causes me issues in
the method I use to have a client identify itself.

I have calls in the server interface where the client hands in a
reference to its CLIENT interface (which is convenient, as they are
all Parcelable).  If the server ever decides it wants to call back to
the client, it simply calls methods on this interface.  HOWEVER...
each time an interface is handed in to the server, it arrives in
server space as a new stub -- there is no means by which they can be
compared against each other and so each client appears new and
distinct every time it calls a function on the server.

Is there any way I can see which of these interfaces are for the same
client, or do I have to code up my own Parcelable class that has a
unique hash of some kind?  For instance, do instances of the "same"
interface already HAVE a hash function on them that would return the
same value?

e,g.:  if I do this...

ServiceConnection serviceConnection = new ServiceConnection() {
                public void onServiceConnected(ComponentName name, IBinder 
                        myService = 
                        try {
                        } catch (RemoteException e) {

                public void onServiceDisconnected(ComponentName name) {
                        myService = null;

and the server's implementation of registerClient() and
doubleCheckThatClientHandle() examine the client interface, there is
no way for it to easily see that the same client is being referred to.

I suppose the lightest weight fix might be for the service to return a
unique GUID when a client registers, and map them on its side.  The
client, in turn, could provide that GUID each time it wants to
identify itself on subsequent function calls.

I hope this makes sense.



3. I found a link for G1 as a modem

4. Killer app - Sync SMS to google on the pc

5. feature/application idea

6. 2D over 3D

7. About porting of bionin libc