Android: SDLActivity safe to subclass?

I’m moving this from the iOS thread.

The topic was subclassing SDLActivity.

I reported a crash in the other thread, but I just figured out why. I
failed to resync with the latest changes in my
current test (which appropriately is the reason I brought this up in
the first place).

However, I’ve been reading the code to SDLActivity in more detail, and
I’m worried that it is not actually safe to subclass. I’m hoping
somebody can explain it to me and convince me that I’m wrong.

This is the problem as I see it. The use of static methods and private
classes will prevent the instantiation of your own subclass and
instead always be instantiating a SDLActivity directly.

This helper class captures the essence for me:

class SDLMain implements Runnable {
public void run() {
// Runs SDL_main()

    //Log.v("SDL", "SDL thread terminated");


Here we have SDLActivity being invoked as static method which calls
the nativeInit method (through JNI). On the native side, the class is
saved as a global variable and used as the activity throughout the
program. I’m a little concerned that you have an instance of
SDLActivity and not the subclass of activity you created.

There are some other things that concern me as well. So originally, I
was thinking I could subclass SDLMain and try to make it directly
invoke my class instead, but it is not public. Furthermore, the way
SDLMain gets invoked is through another private helper class,
SDLSurface. In onSurfaceChanged, which is a relatively, lengthy
function, there is this direct invocation:
final Thread sdlThread = new Thread(new SDLMain(), “SDLThread”);

That means even if I subclassed SDLMain, I would have to somehow
reimplement a chunk of SDLSurface.

But then back in SDLActivity, we have a similar problem with how the
SDLSurface gets created:
mSurface = new SDLSurface(getApplication());

Which means it will be hard to create with your own subclass of SDLSurface.

Furthermore, this variable is used as a static variable which makes me
think there will be more headaches in getting the code to cooperate.

protected static SDLSurface mSurface;

Anyway, I would appreciate an explanation of how this works. The only
solution I have come up with so far is that Android will always only
create a single(ton) activity based on the class you declare in the
manifest and it doesn’t matter you are invoking base class static
methods (as long as you don’t need to change SDLMain or SDLSurface).

Beginning iPhone Games Development