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 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

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can wrap them to choice schema element with maxOccurs… May 16, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer for (var shape in things) { ... This does not… May 16, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer If you want to enlarge the center selected image there… May 16, 2026 at 11:34 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a single-threaded linux app which I would like to make parallel. It
I have heard about portable applications, and I would like to make some of
I'm a bit confused about displaying data from a MySQL database. I would like
Situation I have a few single-responsibility Servlets that take a request, do their job,
I would like to dynamically create a set of labels in an assembly function
I was wondering if its possible to make a single comboBox not visible or
I would like to compare a character literal with the first element of string,
I have developed some reusable android component which is basically a class . This
So here's some code on http://groups.google.com/group/android-developers/browse_thread/thread/16a2216b39513674 in which the poster writes that he's shortened
My programming knowledge is slim, i discovered Java and the Android SDK some days

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.