I've seen this error when trying to set the view on a Dialog after it's been
created. Setting the view as part of the construction process using the
Builder makes it go away.

Maybe try creating the ProgressDialog with the constructor first ("new
ProgressDialog(title, msg, ...), then using the show() method with no
arguments?

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Fri, Nov 13, 2009 at 8:36 AM, Anton Pirker <l...@ignaz.at> wrote:

> I have more information:
>
> The exception is thrown on my htc magic with android 1.5
> But on a htc tattoo with android 1.6 everything works fine.
>
> The code is compiled with Android SDK 1.5r2
>
>
> Maybe there is a problem with the sdk version? I need to get it to
> work on android 1.5, so i thought the best thing would be to compile
> it with sdk 1.5, right?
>
> Any ideas?
>
> regards,
> Anton
>
>
>
>
> On Nov 13, 10:41 am, Anton Pirker <an...@ignaz.at> wrote:
> > Hi fellow Android guys and girls!
> >
> > I have following problem.
> > In my Activity I want to show in onResume() and ProgressDialog.
> >
> > I do this call (where Constants.DIALOG_GET_POSITION is just an integer
> > value):
> >     showDialog(Constants.DIALOG_GET_POSITION);
> >
> > in my onCreateDialog() callback (in the same Activity) I have following
> > code:
> >
> >     protected Dialog onCreateDialog(int id) {
> >         Dialog dialog;
> >         AlertDialog.Builder builder = null;
> >
> >         switch(id) {
> >             case Constants.DIALOG_GET_POSITION:
> >                 dialog = ProgressDialog.show(this, "", "Trying to detect
> > your location. Please wait...", true);
> >                 break;
> >
> >             default:
> >                 dialog = null;
> >         }
> >         return dialog;
> >     }
> >
> > When I run my activity i get an AndroidRuntimeException:
> > requestFeature() must be called before adding content
> > This error is on the line where I call showDialog();
> >
> > Here the Stacktrace:
> >
> > 11-13 10:25:02.195: ERROR/AndroidRuntime(3266): Uncaught handler: thread
> > main exiting due to uncaught exception
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):
> > java.lang.RuntimeException: Unable to resume activity
> > {at.ignaz.UrbanGolf/at.ignaz.UrbanGolf.Activity.SetupActivity}:
> > android.util.AndroidRuntimeException: requestFeature() must be called
> > before adding content
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> >
> android.app.ActivityThread.performResumeActivity(ActivityThread.java:2632)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2647)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2287)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.ActivityThread.access$1800(ActivityThread.java:112)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.os.Handler.dispatchMessage(Handler.java:99)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.os.Looper.loop(Looper.java:123)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.ActivityThread.main(ActivityThread.java:3948)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > java.lang.reflect.Method.invokeNative(Native Method)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > java.lang.reflect.Method.invoke(Method.java:521)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> >
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > dalvik.system.NativeStart.main(Native Method)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266): Caused by:
> > android.util.AndroidRuntimeException: requestFeature() must be called
> > before adding content
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> >
> com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:286)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> >
> com.android.internal.app.AlertController.installContent(AlertController.java:198)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.AlertDialog.onCreate(AlertDialog.java:251)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.ProgressDialog.onCreate(ProgressDialog.java:176)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.Dialog.dispatchOnCreate(Dialog.java:287)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.Activity.showDialog(Activity.java:2402)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> >
> at.ignaz.UrbanGolf.Activity.SetupActivity.onResume(SetupActivity.java:247)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> >
> android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1229)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> > android.app.Activity.performResume(Activity.java:3530)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     at
> >
> android.app.ActivityThread.performResumeActivity(ActivityThread.java:2619)
> > 11-13 10:25:02.345: ERROR/AndroidRuntime(3266):     ... 12 more
> >
> > What am I doing wrong? I could swear that this code was working already.
> > Any hints or tips?
> >
> > Thanks in advance,AntonPirker
> >
> > --
> > DI(FH)AntonPirker
> >
> > ------------------------------
> > cross platform mobile software
> > burggasse 123/53
> > a-1070 wien
> > tel: +43 699 1234 0 456
> > skype: antonpirker
> >
> > http://anton-pirker.at
>
> --
> 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<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
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

Reply via email to