AsyncTask and ProgressDialog error

alberto.palberto.p Alberto PiccininITMember
edited March 2013 in Android

Hi,
I get an error at dialog dismiss on OnPostExecuted() into AsyncTask.

protected override void OnPostExecute (bool result)
{
base.OnPostExecute (result);
if (dlgLoad != null)
{
if (dlgLoad.IsShowing)
dlgLoad.Dismiss ();
}
}

The Progress dialog is created on OnPreExecute()

How can I do?

Thanks Alberto

Posts

  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    I get an error at dialog dismiss on OnPostExecuted() into AsyncTask.

    What's the error dialog, and does the android debug log contain anything relevant?

  • alberto.palberto.p Alberto Piccinin ITMember

    Dialog has not attach in window

  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    @alberto.p: Can you please provide the full android debug log output, including any stack traces, and messages both before and after the "Dialog has not attach in window" message?

  • alberto.palberto.p Alberto Piccinin ITMember
    edited March 2013

    @jonp the Error message is "View not attached to window manager"

    {Java.Lang.IllegalArgumentException: Exception of type 'Java.Lang.IllegalArgumentException' was thrown.
    at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod) [0x00022] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:356
    at Android.App.Dialog.Dismiss () [0x0003e] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.App.Dialog.cs:385
    at Misurate.VerifyActivity+VerifyMisurate.OnPostExecute (Boolean result) [0x00015] in f:\Sviluppo_Android\Misurate\VerifyActivity.cs:251
    --- End of managed exception stack trace ---
    java.lang.IllegalArgumentException: View not attached to window manager
    at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355)
    at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200)
    at android.view.Window$LocalWindowManager.removeView(Window.java:432)
    at android.app.Dialog.dismissDialog(Dialog.java:278)
    at android.app.Dialog.access$000(Dialog.java:71)
    at android.app.Dialog$1.run(Dialog.java:111)
    at android.app.Dialog.dismiss(Dialog.java:268)
    at misurate.VerifyActivity_VerifyMisurate.n_onPostExecute(Native Method)
    at misurate.VerifyActivity_VerifyMisurate.onPostExecute(VerifyActivity_VerifyMisurate.java:46)
    at android.os.AsyncTask.finish(AsyncTask.java:417)
    at android.os.AsyncTask.access$300(AsyncTask.java:127)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3687)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    at dalvik.system.NativeStart.main(Native Method)
    }
  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    Error message is "View not attached to window manager"

    The question remains: why is the View not attached? This is where more adb logcat output would be useful. Could you attach all the adb logcat output from before the start of your app until after you get this exception?

  • alberto.palberto.p Alberto Piccinin ITMember

    @jonp I attached logcat file.
    The error happens when I rotate the device

    txt
    txt
    logcat.txt
    898K
  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    ...and the error in the log file differs from the previous error

    Fun.

    The current error:

    E/WindowManager(28482): Activity misurate.VerifyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4057b0f8 that was originally added here
    E/WindowManager(28482): android.view.WindowLeaked: Activity misurate.VerifyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4057b0f8 that was originally added here
    E/WindowManager(28482): at android.view.ViewRoot.<init>(ViewRoot.java:263)
    E/WindowManager(28482): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
    E/WindowManager(28482): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
    E/WindowManager(28482): at android.view.Window$LocalWindowManager.addView(Window.java:424)
    E/WindowManager(28482): at android.app.Dialog.show(Dialog.java:241)
    E/WindowManager(28482): at android.app.ProgressDialog.show(ProgressDialog.java:107)
    E/WindowManager(28482): at android.app.ProgressDialog.show(ProgressDialog.java:90)
    E/WindowManager(28482): at misurate.VerifyActivity_VerifyMisurate.n_onPreExecute(Native Method)
    E/WindowManager(28482): at misurate.VerifyActivity_VerifyMisurate.onPreExecute(VerifyActivity_VerifyMisurate.java:30)
    E/WindowManager(28482): at android.os.AsyncTask.execute(AsyncTask.java:391)
    E/WindowManager(28482): at misurate.VerifyActivity.n_onCreate(Native Method)
    E/WindowManager(28482): at misurate.VerifyActivity.onCreate(VerifyActivity.java:34)
    E/WindowManager(28482): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    E/WindowManager(28482): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
    E/WindowManager(28482): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
    E/WindowManager(28482): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    E/WindowManager(28482): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
    E/WindowManager(28482): at android.os.Handler.dispatchMessage(Handler.java:99)
    E/WindowManager(28482): at android.os.Looper.loop(Looper.java:130)
    E/WindowManager(28482): at android.app.ActivityThread.main(ActivityThread.java:3687)
    E/WindowManager(28482): at java.lang.reflect.Method.invokeNative(Native Method)
    E/WindowManager(28482): at java.lang.reflect.Method.invoke(Method.java:507)
    E/WindowManager(28482): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    E/WindowManager(28482): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    E/WindowManager(28482): at dalvik.system.NativeStart.main(Native Method)
    E/ERROR (28482): ------>Exception of type 'Java.Lang.IllegalArgumentException' was thrown.

    A Google search suggests that you may not be dismissing the dialog.

  • alberto.palberto.p Alberto Piccinin ITMember

    @jonp
    sorry about that, but if I check message error in breakpoint line I saw previous error, while in the logcat I saw last error

  • alberto.palberto.p Alberto Piccinin ITMember

    I solved with onfigurationChanges=Android.Content.PM.ConfigChanges.Orientation

Sign In or Register to comment.