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

  • Home
  • SEARCH
  • 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 1017913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:46:40+00:00 2026-05-16T10:46:40+00:00

I would like to make a single Android app for multiple Android versions (possibly

  • 0

I would like to make a single Android app for multiple Android versions (possibly every one of them)
My problem is that I want to check what is the version of Android the app is currently running on, and dynamically load a class which is version dependent. This part should be ok.

I just wonder how I can achieve that without compilation errors in my Eclipse project.
I mean, the project is configured for a particular target (1.5, 2.1 …), so if a class in my project is not compatible wich the selected target, it will result in errors.

Is there a way to export this classes even if they are not fit for the platform (I thought about a separated lib, but then again : how to compile theses classes into a lib without compilation pbs?) ? This should be ok since they won’t be loaded until I ask them to after having checked Android version.

Thanks!

  • 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-05-16T10:46:41+00:00Added an answer on May 16, 2026 at 10:46 am

    You could use Class.forName to load different classes depending on different conditions:

    public interface MyType {}
    public class MyTypeOn15 implements MyType {}
    public class MyTypeOn16 implements MyType {}
    public class MyTypeOn20 implements MyType {}
    // ...
    

    and somewhere else in your code:

    MyType myType = null;
    if (getActualTarget().equals("1.5") {
       myType = Class.forName("MyTypeOn15").newInstance();
    } else if (getActualTarget().equals("1.6") {
       myType = Class.forName("MyTypeOn16").newInstance();
    } // ...
    

    Note that you need an accessible empty constructor in your implementations. And getActualTarget() is your magic method that’s returns the target as a String identifier…

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

Sidebar

Related Questions

I'm new to android programming. I would like to make an app widget that
I've got 30+ single bitmaps (320x240 pixels) that I would like to display one
I have a single-threaded linux app which I would like to make parallel. It
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make my app freeware, but if a user is willing
I would like to make a function that takes in a list of integers
I would like to make several statements that give standard output without seeing newlines
I would like to make a function that will create objects that have a
I have an app that has a ListBox of ListBoxes. I would like to
I'm just trying to make an android app design similar to the one in

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.