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. A lot of graphics in drawable-folder

Hi, I have plenty of image files in my drawable folder because my
application has different skins. This makes it very unmanageable. But
is there a better to organize the graphics, like folders, groups or
such things? Or is it a good idea to not use the drawable resource,
but instead create a xml file in the application directory for each
skin with the image-links?

2. SimpleCursorAdapter and blobs

the favicon field returned by the browser bookmark provider is a
sqlite blob.
I want to display the bookmarks in a listview with the favicon but
couldn't find a way to do it.
I tried using a SimpleCursorAdapter.ViewBinder but I get an exception.

this is what my code looks like :

                Cursor bookmarks;
                String[] proj = new String[] {
                bookmarks = managedQuery(android.provider.Browser.BOOKMARKS_URI,
proj, null, null, android.provider.Browser.BookmarkColumns.URL  + "

                SimpleCursorAdapter adapter = new SimpleCursorAdapter(
                                new String[] 
                                new int[] {,,});
                adapter.setViewBinder(new BookmarkDataViewBinder());

and this is my viewbinder class :

class BookmarkDataViewBinder implements SimpleCursorAdapter.ViewBinder
        public boolean setViewValue(View view, Cursor cursor, int
columnIndex) {
if(view.getClass().getName().equals("android.widget.ImageView")) {
                        byte[] b = cursor.getBlob(columnIndex);
                        if(b != null) {
                                Bitmap bitmap = 
BitmapFactory.decodeByteArray(b, 0, b.length);
                        else {
                        return true;
                return false;

if the favicon blob field is null, the viewbinder does its job and it
displays the default icon. but if it is not null, this is the
exception I get :

E/AndroidRuntime( 1365): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 1365): android.database.sqlite.SQLiteException:
unknown error: Unable to convert BLOB to string
E/AndroidRuntime( 1365):        at
android.database.CursorWindow.getString_native(Native Method)
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at android.widget.CursorAdapter.getView
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at android.widget.ListView.fillDown
E/AndroidRuntime( 1365):        at android.widget.ListView.fillGap
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at android.widget.AbsListView
E/AndroidRuntime( 1365):        at android.os.Handler.handleCallback
E/AndroidRuntime( 1365):        at android.os.Handler.dispatchMessage
E/AndroidRuntime( 1365):        at android.os.Looper.loop(
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1365):        at java.lang.reflect.Method.invoke
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at
E/AndroidRuntime( 1365):        at dalvik.system.NativeStart.main
(Native Method)

according to my logs, the exception occurs before my viewbinder is

can somebody help?


3. Terminal and su error

4. why my setting dns can't work

5. NotePad tutorial, trouble removing notes

6. how to use HTTP Session with StreamingMediaPlayer

7. ADT Plugin