Abstract Class Question


#1

I had code in the original CrimeActivity that logged the invocation of onCreate and used the tag CrimeActivity. Now that we are using the abstract class how can I make SingleActivityFragment produce a tag that represents the name of the class that uses the abstract class (CrimeActivity and CrimeListActivity for example). I know this is more of a Java question than Android but would appreciate an answer!


#2

Interesting question! You could do this by calling getClass().getSimpleName() at runtime. You might want to wrap this in an instance method named getTag().


#3

Thanks - I find logging the invocation of all the methods in activities and fragments very helpful to understanding the order of execution/invocation etc, so I tag and log EVERYTHING!


#4

This is a nice tip for learning, thanks!