ProgressDialog in Thread stopps when closing G1

by Manfred » Fri, 06 Mar 2009 16:24:02 GMT


Sponsored Links
 Hi!

I have a Progress Dialog in an extra Thread running. Normally the user
will have the keyboard open, because something is to insert! So when
the Progress Dialog appears and the user close the keyboard, the
dialog dissappears and the application crashes. In the debugger i saw
the exception "View not attached to window manager". May because the
Dialog is not longer shown but the application want to remove it after
the calculation?

Here is the code where i start the dialog and the thread:
------------------------------------------------------------------------------------------
        alert=0;
        myProgressDialog = ProgressDialog.show(this,
                                "Please wait...", "Calculating..", true);
        new Thread()
        {
            public void run()
            {
                                try
                                {
                                        //Doing some stuff....
                                }
                                catch (Exception e)
                                {
                                        alert=2;
                                        alertText = e.getMessage();
                                }

                                myProgressDialog.dismiss();
                                mHandler.post(mCompleteRunnable);
            }
        }.start();
------------------------------------------------------------------------------------------

Does somebody know how to solve this?

Thanks!
--~--~---------~--~----~------------~-------~--~----~



ProgressDialog in Thread stopps when closing G1

by Manfred » Fri, 06 Mar 2009 16:53:59 GMT


 Thanks




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


ProgressDialog in Thread stopps when closing G1

by Manfred » Fri, 06 Mar 2009 20:36:40 GMT


 For all who have the same problem, this helps:

Override this method:
        @Override
        public void onConfigurationChanged(Configuration arg0)
        {
                super.onConfigurationChanged(arg0);
                //Toast.makeText(this, "onConfigurationChanged",
Toast.LENGTH_SHORT).show();
        }

And in Manifest XML insert this line in the activity tag:
android:configChanges="keyboardHidden|orientation">

Now you have to handle yourself changes on orientation and
keyboardHidden, and as you can see in the overridden method, i do
nothing. So the onCreate() Method is not called if the orientation
changes or if the keyboard is slided out or in and therefore the
dialog do not dissappear!






--~--~---------~--~----~------------~-------~--~----~



ProgressDialog in Thread stopps when closing G1

by MrSnowflake » Sat, 07 Mar 2009 23:07:06 GMT


 lso using showDialog() and corresponding onCreateDialog and
onPrepareDialog() will have dialogs survive configuration changes!
(and it's a lot easier :)).

On 6 mrt, 13:36, Manfred <manfred.fettin...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Layout support two items in a 'row' filling width?

You can use a LinearLayout and the android:layout_weight attribute on
the Spinner. There are many examples of this around.






-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~

2. About building Single module

Hi All,
           can anybody tell me that how to build single module at a
time from android source code?
           Is there any way to build module like sqlite only from
whole source code .
           Plesse reply me.


Regards,
Dhananjay
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. How to download Android source code distribution in sync with Android SDK?

4. dealing with multiple activities

5. New SDK release

6. Debug Android G1 on FreeBSD

7. Google Apps for Business - No Android Support?