# LifeCycle callbacks

**URL:** <https://discourse.processing.org/t/lifecycle-callbacks/1305>\
**Category:** Processing for Android\
**Created:** [June 27, 2018, 9:22am UTC](https://discourse.processing.org/t/lifecycle-callbacks/1305 "2018-06-27T09:22:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [June 27, 2018, 9:22am UTC](https://discourse.processing.org/t/lifecycle-callbacks/1305/1 "2018-06-27T09:22:28Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [June 27, 2018, 10:38am UTC](https://discourse.processing.org/t/lifecycle-callbacks/1305/2 "2018-06-27T10:38:09Z")

</div>

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](https://github.com/processing/processing-android/wiki/Lifecycle-of-a-Processing-sketch)

Kf

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [June 27, 2018, 11:10am UTC](https://discourse.processing.org/t/lifecycle-callbacks/1305/3 "2018-06-27T11:10:53Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [June 27, 2018, 11:35am UTC](https://discourse.processing.org/t/lifecycle-callbacks/1305/4 "2018-06-27T11:35:27Z")

</div>

> [@shedMusic](#):
>
> I was just wondering why it is showing as an unrecognised method in the Processing IDE

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.

> [@shedMusic](#):
>
> to override these callbacks, I don’t seem to actually have to include @override in my code

Yes, `@Override` is an anootation and it is not mandatory. Check [this](https://www.quora.com/Is-it-mandatory-to-write-override-in-Java-when-overriding-or-is-that-just-a-standard-syntax). 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

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [June 27, 2018, 11:43am UTC](https://discourse.processing.org/t/lifecycle-callbacks/1305/5 "2018-06-27T11:43:06Z")

</div>

Thanks again Kf … it’s all becoming clearer to me now.
