No dispatching events with FragmentActivity

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

Antonio
Posts: 3
Joined: 17 Dec 2012, 17:37

No dispatching events with FragmentActivity

Postby Antonio » 18 Dec 2012, 09:06

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.
Antonio
Posts: 3
Joined: 17 Dec 2012, 17:37

Re: No dispatching events with FragmentActivity

Postby Antonio » 18 Dec 2012, 11:26

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.
User avatar
Lapo
Site Admin
Posts: 21090
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: No dispatching events with FragmentActivity

Postby Lapo » 18 Dec 2012, 16:17

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?
Lapo
--
gotoAndPlay()
...addicted to flash games
Antonio
Posts: 3
Joined: 17 Dec 2012, 17:37

Re: No dispatching events with FragmentActivity

Postby Antonio » 19 Dec 2012, 16:20

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.
User avatar
Lapo
Site Admin
Posts: 21090
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: No dispatching events with FragmentActivity

Postby Lapo » 19 Dec 2012, 16:31

Good to know. Is this normal in Android? I mean the lack of context for the Threads?
I guess, it shouldn't.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 4 guests