Page 1 of 1

No dispatching events with FragmentActivity

Posted: 18 Dec 2012, 09:06
by Antonio
Hello,

I am developing a georreferenced game using SmartFoxServer and Google Maps API V1. Everything was ok but few days ago Google has launched Google Maps API V2 and we must use it in the game. SmartFox is instantiated in a class what extends of FragmentActivity (Android Support Library) and from this time, dispatch method from IEventListener Interface is not working. Before everything was ok. If I remove FragmentActivity extends, game works properly again. So, because of that I think what is wrong could be related with FragmentActivity and the fact of make running dispatch on UI thread.

Can somebody help me, please? Thank you.

Re: No dispatching events with FragmentActivity

Posted: 18 Dec 2012, 11:26
by Antonio
Adding more information:

I am new using Fragment, but I have tried to implement my own class extending of Fragment class, and I have used FragmentActivity in main class where sfsClient is (i have tried to imitate Google Map Api v2 structure). The result is everything works ok using my own Fragment. So, I think it's a problem beetween sfsClient and com.google.android.gms.maps.SupportMapFragment.

Please, I need help! Thank you.

Re: No dispatching events with FragmentActivity

Posted: 18 Dec 2012, 16:17
by Lapo
I am not familiar with the Android SDK but I don't see a good reason for the events to cease to work.
I think at the very least you should notice errors in the application logs.

As regards running the UI thread I don't think it's a problem because in any case the main thread starting your application is the UI thread.

Finally can you clarify how this problems work?
You have a certain class, let's call it MyApp, that extends FragmentActivity and which contains an instance of SmartFox, is this correct?

Re: No dispatching events with FragmentActivity

Posted: 19 Dec 2012, 16:20
by Antonio
Firstly, thank Lapo for your post.

The incidence has been resolved. It was due of thread what is connecting with smartfoxserver ( sfsClient.connect(ip,port) ) had not context class loader seted. So, we had to set its loader class properly with setContextClass(ClassLoader cl) method and now is working.

Thank for your time.

Re: No dispatching events with FragmentActivity

Posted: 19 Dec 2012, 16:31
by Lapo
Good to know. Is this normal in Android? I mean the lack of context for the Threads?
I guess, it shouldn't.

Cheers