I am working on creating abstract activity classes for my application that I will reuse for each activity.
Super Class: android.app.Activity
My Abstract Class extends android.app.Activity myActivity
Example activty in my application extends myActivity.
I will have 10-20 of these exampleActivity
.
How can I write my abstract class (#2) to force my example class to override methods in android.app.Activity
like onCreate()
and onStart()
?
Is this possible in Java?
Not really.
However you can create abstract functions myOnCreate and myOnStart and call those in your abstract class implementation of onCreate and onStart.
You might also want to make onCreate/onStart final, although it's difficult to see what the benefit is of forcing myOnCreate instead of onCreate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With