I am implementing a library that will be used by many different types of media players. I need to use a getPosition method that will vary for each individual user's video player.
Currently to accomplish this I have made my library an abstract class the user has to extend and then override the getPosition method with whatever object/method they use to get the position of their media player.
I am trying to make it so my class does not have to be abstract and that they could define this getPosition method for my library without having to extend my abstract class (i.e.) I don't want my library class to be abstract.
I have looked into using Reflection, but I am struggling with it because I do not know the class name/method name/parameters until runtime and I want the position of a specific instance of the media player object so I can get the most current position.
What's good practice for the Java/Android programming paradigm?
Is reflection the way to go? And if so could I see some sample code for this specific instance (Unknown class name/method name/parameters to be used by my imported library etc...)
Or is there a better way to accomplish this/is making my class abstract the way to go in Java?
Again I would prefer if the user did not have to extend my class and could just call some sort of setGetPosition() method on an object.
EDIT: Simply put: I want to be able to use an unknown class's getPosition method in my library, but I don't want my entire class to be abstract