Start jpct-ae fresh when activity starts.

Started by dajack05, December 20, 2011, 04:06:52 AM

Previous topic - Next topic

dajack05

Here is my issue... I am launching an activity which holds all the jpct-ae stuff. But I want to be able to quit that activity and then start it again later but it needs to start fresh (Like from onCreate).

I have tried calling finish() at onPause() and I have noHistory set as True but it always wants to resume from where it was before.

Any advice?

Thx in advanced,
Daniel

EgonOlsen

There might be a cleaner solution, but if i want this behaviour, i usually do a System.exit(0); in all these doPause()/doStop()/...-methods(). That terminates the VM and frees all resources.

redfalcon

Where do you initialize the jpct-stuff? You likely want to put it into a method and call it in onCreate() and onResume().

EgonOlsen

In onCreate()...as you can see in the examples. But i don't claim that that's the best way. My understanding of Android's lifecycle management is limited... ;)

redfalcon

I was asking the thread author ;)

Usually, onCreate is only called if the activity is, well, created. If you switch to another activity, the current one is paused. If you switch back to the paused activity onResume() is called. But since on switching activites the OpenGL context may get destoyed and you need to re-initialize your 3D-stuff. Depending on where you do that, onResume() or onSurfaceChanged() is a good place to do so.

dajack05

I am loading everything in "if (master == null)" under "public void onSurfaceChanged(GL10 gl, int w, int h)"

So I should put all my code for loading in another function and then call that at onCreate()?

dajack05

I GOT IT! lol
I just needed to set master to null and flush the textures and now it works perfectly.

Thanks for your help guys :)