Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8042703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:40:26+00:00 2026-06-05T04:40:26+00:00

I am implementing a library that will be used by many different types of

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:40:28+00:00Added an answer on June 5, 2026 at 4:40 am

    That’s what interfaces are for–to enforce API obligations.

    Classes implementing Positionable (or whatever) can be (a) referenced as a Positionable, and (b) handle calls to Positionable‘s methods, like getPosition.

    Consider the List interface: any class that implements List must have a bunch of specific methods, but they don’t need to be a subclass. They may be a subclass, but don’t have to be.

    In general, “plugin” systems allow arbitrary implementations of specific functionality, and the functionality is specified using an interface. Interfaces are one of the most basic mechanisms Java provides for forcing classes to adhere to a spec.

    Plugins may use reflection, but there’s additional overhead, additional complexity, and allows undesirable runtime behavior precisely because there’s no compiler enforcement as with interfaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing a library that will be used to intercept and process incoming messages
I've started implementing a UIScrollView that will contain many thumbnail-sized pictures and will scroll
I'm currently implementing a JavaScript library that keeps track of the history of changes
i am trying to use php-openid library for implementing openID in my site. the
I'm implementing the Enterprise Library Exception Handling Application Block in an ASP.NET application that
I am looking into implementing a simple crash report on my application that will
I am implementing a small library to make the use of System.Net.Sockets.Socket easier. It
I'm implementing a cache in a class library that i'm using in an asp.net
I am implementing a piece of Java software that will hopefully allow for C
I have a library project that I created and have used in about three

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.