LifeCycle callbacks


#1

Hi ALL !
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 :slight_smile:

p.s it’s great to have the onBackPressed() functionality back with the latest Android Mode release. Big thumbs up for that!


#2

There is an example of how to call onCreate() here. Make sure you are calling it with the right parameters. Related to onRestart(), this method is probably not exposed. You should submit a github ticket as a feature request.

Relevant source code: https://github.com/processing/processing-android/blob/cb84ca98fc9b0b14e695fe3835570fd23548bbec/core/src/processing/android/ActivityAPI.java

Kf


#3

@tonlymutan===
trying to understand the android lifecycle is a very good idea! - Yet, as for P5, as you are in a Fragment you have to think that some of the events are not called or are not (exactly) at the same moment: as for onCreate() that is fired at first by the Activity and that is the example given by @kfrajer, but in a fragment it s called after onAttach() and before onViewCreated() and so on. Practically, as for P5, it seems to me that if you dont add code to the mainActivity (which means using AS) main events to know and use are onStart(), onResume(), on Pause() and onStop(). As for onRestart() i dont know this event.