[mono-android] Calling OnStart causes ForceClose

Jonathan Pryor jpryor at novell.com
Sun Mar 27 10:21:04 EDT 2011


On Mar 27, 2011, at 9:28 AM, <www at gencode.com> <www at gencode.com> wrote:
> If I put this in my activity
>         protected override void OnStart()
>  
> I get a force close.

Please provide the `adb logcat` output.

Now, by "force close" do you mean the "Application Not Responding" dialog, which asks you whether you want to Wait or Force Close?

> I put a call to a webservice in the
>         protected override void OnCreate(Bundle bundle)
>  
> but it crashes so I think I need to wait further in the lifecycle, I assume the best place for this is on the OnStart?

Again, please provide the `adb logcat` output.

I suspect that the problem is that you're doing the webservice call on the main thread. If e.g. OnCreate() or OnStart() take too long to execute (iirc ~5s), then the Application Not Responding dialog is shown. Te only way to avoid this is to spawn another thread to do the webservice call (allowing the main thread to return), and have the new thread perform the webservice call then use Activity.RunOnUiThread() to update the UI.

 - Jon



More information about the Monodroid mailing list