Just a quick one this…
I’m exploring the lifecycle callbacks to gain a better understanding of what is going on, but I can’t call super.onRestart() or super.onCreate() … all others … .super.onStart() …onPause(), etc are all fine.
I am assuming this is deliberate for some reason … am I not allowed to tinker with onRestart() and onCreate() in Processing? It’s not critical for me, but i’d just like to know
p.s it’s great to have the onBackPressed() functionality back with the latest Android Mode release. Big thumbs up for that!
You are calling these functions inside the override methods? I don’t recognize onRestart()
. What do you mean you can’t call them? Maybe this comes handy: https://github.com/processing/processing-android/wiki/Lifecycle-of-a-Processing-sketch
Kf
Hi Kf
Thanks for replying
OK … call is the wrong word … I meant I can’t override … the system makes the calls and I can override if I want to.
I was just struggling with onCreate() not working but I have fixed that now by importing android.os.Bundle and passing the Bundle as required in the callback.
The onRestart() callback is between onStop() and onStart() on the lifecycle flow diagram in the android developer guide … I was just wondering why it is showing as an unrecognised method in the Processing IDE … I am guessing I now need another import … currently looking
Also, as a point of interest, to override these callbacks, I don’t seem to actually have to include @override in my code but simply use void onPause(){}. I assume the magic of the Processing IDE and Android mode knows that it’s an override somehow!
It is likely that it is not explicitly defined in the Android mode source code. If you want, you can did into the code and see if it is implemented there. Nevertheless, the method should exist if it is defined as part of the Android API and if it does, you should be able to override it if it was design to do so.
Yes, @Override
is an anootation and it is not mandatory. Check this. From this link I quote:
It’s certainly not mandatory to use @Override, and you should be able to guess why: because code written for Java 1.4 and earlier didn’t support annotations
Kf
Thanks again Kf … it’s all becoming clearer to me now.