Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating abstract Activity classes

I am working on creating abstract activity classes for my application that I will reuse for each activity.

  1. Super Class: android.app.Activity

  2. My Abstract Class extends android.app.Activity myActivity

  3. 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?

like image 756
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Avatar asked Apr 25 '11 02:04

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz


1 Answers

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.

like image 103
Phil Lello Avatar answered Sep 27 '22 22:09

Phil Lello