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 4000456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:47:02+00:00 2026-05-20T07:47:02+00:00

I am programming for Android 1.6, the following code works in 2.2 (API Level

  • 0

I am programming for Android 1.6, the following code works in 2.2 (API Level 5):

  Intent intentChooser = Intent.createChooser(intent, "Choose between these programs");

  Intent intentTest= new Intent(Intent.ACTION_VIEW);  
  ....
  Parcelable [] parcelable = new Parcelable [1]; 
  parcelable[0] = new LabeledIntent(intentTest, "", "the text of the label", 0);
  intentChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, parcelable);
  activity.startActivity(intentChooser);

I don’t know if the parcelable can include another type of data (not LabeledIntent). That would be a possible solution.

I have tried to include the code of LabeledIntent in my project, I have found here:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/android/content/pm/LabeledIntent.java

but no success. That would be another question, how to include classes of later versions in older Android versions.

Any ideas?

  • 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-20T07:47:02+00:00Added an answer on May 20, 2026 at 7:47 am

    The user Commonsware gave me the solution:
    Android: how to code depending on the version of the API?

    The solution was to create a proxy class, so that determining if the sdk was < than level 5, I instanced a class that did not include the LabeledIntent class, only available from 2.0 on.

    The one thing one has to bear in mind is that you cannot instance any class that includes a reference to a package / class from a more modern sdk. So in fact, with the code below I never reference the class (LabeledIntentNew) that had the reference to LabeledIntent, if the sdk was < than 5.

    That is the code:

    public abstract class LabeledIntentBridge {
        public abstract Intent BuildLabeledIntent(String URL, Intent intent, Activity activity);
    
        public static final LabeledIntentBridge INSTANCE=buildBridge();
    
        private static LabeledIntentBridge buildBridge() {
            int sdk=new Integer(Build.VERSION.SDK).intValue();
    
            if (sdk<5) {
                return(new LabeledIntentOld());
            }
            return(new LabeledIntentNew());         
    
        }
    }
    

    To instance this class you do:

    activity.startActivity(LabeledIntentBridge.INSTANCE.BuildLabeledIntent(
                                URL,
                                        theIntent,
                                                           activity     
                        )   
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Programming is learned by writing programs. But code reading is said to be another
Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping,
I want to learn some programming for my android phone. I was successful doing
I'm currently programming an application for the Android. Now what I found out is
I am programming Android applications, and the best way here may or may not
I'm rather new to both Java programming and to Android development, so my learning
I'm very new to programming in Android, but have been struggling all day with
Am very new to Android programming, so sorry if this is a simple problem.
I am new to Java programming / Android development - but I have been
I am doing Android programming and was learning about Intents, when I saw a

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.