SDL2 Android Intents

Hello,

I have an Android app created using SDL2. I would like to fire off an Intent. In order to do this, I need to call a function in my
testActivity (extends SDLActivity) from within my C++ code. Everything seems to be going well until I call GetMethodID() from with C++.
GetMethodID() causes an exception to be thrown (see below).

My search results seem to suggest that this may not be possible with non-UI threads? Before I dive into SDLActivity.java, I thought I would
ask if anyone on here has use SDL2 on Android and been able to call functions from their derived activity (upcall)?

java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare()
at android.os.Handler.(Handler.java:121)
at android.app.Activity.(Activity.java:735)
at org.libsdl.app.SDLActivity.(SDLActivity.java:23)
at com.example.test.testActivity.(testActivity.java:6)
at org.libsdl.app.SDLActivity.nativeInit(Native Method)
at org.libsdl.app.SDLMain.run(SDLActivity.java:424)
at java.lang.Thread.run(Thread.java:856)
“SDLThread” prio=5 tid=12 NATIVE
| group=“main” sCount=0 dsCount=0 obj=0x4102dce0 self=0x1b0180
| sysTid=681 nice=0 sched=0/0 cgrp=default handle=1770960
| schedstat=( 863492026 442488169 221 ) utm=75 stm=11 core=0
at org.libsdl.app.SDLActivity.nativeInit(Native Method)
at org.libsdl.app.SDLMain.run(SDLActivity.java:424)
at java.lang.Thread.run(Thread.java:856)
VM aborting
Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

Thanks,

Alvin

Hello,

Well, I should have dove into the source first! The problem was that I was trying to call the Java function from scratch.
Instead, I switched to SDL_AndroidGetJNIEnv()[1] and SDL_AndroidGetActivity()[2] which solved the problem! Works perfectly!
The documentation for those functions give an excellent example.

In regards to the API documentation (wiki.libsdl.org), I couldn’t find those functions through the “API By Name” nor “API By Category”.
I had to “Search Wiki”. For future reference, were can I find the platform specific documentation?

Cheers,

Alvin

[1] http://wiki.libsdl.org/SDL_AndroidGetJNIEnv
[2] http://wiki.libsdl.org/SDL_AndroidGetActivityOn 19/11/13 16:38, Alvin Beach wrote:

Hello,

I have an Android app created using SDL2. I would like to fire off an Intent. In order to do this, I need to call a function in my
testActivity (extends SDLActivity) from within my C++ code. Everything seems to be going well until I call GetMethodID() from with C++.
GetMethodID() causes an exception to be thrown (see below).

My search results seem to suggest that this may not be possible with non-UI threads? Before I dive into SDLActivity.java, I thought I would
ask if anyone on here has use SDL2 on Android and been able to call functions from their derived activity (upcall)?

java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare()
at android.os.Handler.(Handler.java:121)
at android.app.Activity.(Activity.java:735)
at org.libsdl.app.SDLActivity.(SDLActivity.java:23)
at com.example.test.testActivity.(testActivity.java:6)
at org.libsdl.app.SDLActivity.nativeInit(Native Method)
at org.libsdl.app.SDLMain.run(SDLActivity.java:424)
at java.lang.Thread.run(Thread.java:856)
“SDLThread” prio=5 tid=12 NATIVE
| group=“main” sCount=0 dsCount=0 obj=0x4102dce0 self=0x1b0180
| sysTid=681 nice=0 sched=0/0 cgrp=default handle=1770960
| schedstat=( 863492026 442488169 221 ) utm=75 stm=11 core=0
at org.libsdl.app.SDLActivity.nativeInit(Native Method)
at org.libsdl.app.SDLMain.run(SDLActivity.java:424)
at java.lang.Thread.run(Thread.java:856)
VM aborting
Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

Thanks,

Alvin