Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strategies for Honeycomb & backward compatibility

So we've seen the preview sdk and the neat new stuff like ActionBar and Fragments. Making a lot of method calls will be unavoidable to make use of these, so what strategies are there for maintaining 1 version of the app, which will let me use all the snazzy new stuff but also work on devices running 2.3 or below? My app targets 1.5 - 2.3 at the moment.

like image 344
Al. Avatar asked Jan 28 '11 19:01

Al.


People also ask

What is the honeycomb model marketing?

The idea behind the honeycomb model is that of the 7 key building blocks delineated by the model, companies can select the ones most relevant to their business, and focus their attention on the key functionalities.

What is honeycomb used for in education?

Layers of the Honeycomb Model Comprehensive, data-rich learner profiles are used WITH the student to plan a customized learning environment and instructional strategies. How do the students acquire information, express information, and engage with information?

Who created the honeycomb model?

The seven functional blocks of social media. Kietzmann, Hermkens, McCarthy, and Silvestre (2011) developed a honeycomb framework that identifies seven functional building blocks of SM: identity, conversations, sharing, presence, relationships, reputation and groups.

Which of the following are blocks in the honeycomb framework?

In this presentation, we present a framework that defines social media using seven functional building blocks: identity, presence, relationships, conversations, groups, reputations and sharing.


1 Answers

The same fragment APIs are now available as a static library for use with older versions of Android; it's compatible right back to Android 1.6.

There are a few tricks you can use to see if the various new APIs are available to your app. Generally speaking, you'll probably want to create two alternative sets of Activities, one that uses the fancy new APIs (ActionBar, Animators, etc.) -- and another set that don't.

The following code shows how you can use reflection and exception catching to determine the availability of the Fragment APIs, and version checking to confirm if the other Honeycomb APIs are available.

  private static boolean shinyNewAPIsSupported = android.os.Build.VERSION.SDK_INT > 10;    private static boolean fragmentsSupported = false;    private static void checkFragmentsSupported() throws NoClassDefFoundError {     fragmentsSupported = android.app.Fragment.class != null;   }    static {     try {       checkFragmentsSupported();     } catch (NoClassDefFoundError e) {       fragmentsSupported = false;     }   }    @Override   public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);      Intent startActivityIntent = null;     if (!shinyNewAPIsSupported)       startActivityIntent = new Intent(this, MainNonActionBarActivity.class);     else       startActivityIntent = new Intent(this, MainActionActivity.class);      startActivity(startActivityIntent);     finish();   } 

Generally speaking you can use the same layout definitions. Where Fragments are available you'll inflate each layout within a different Fragment, where they aren't you'll probably want to use <include> tags to embed several of them into a more complex Activity layout.

A more detailed work through of how to write the code to support backwards compatibility on Honeycomb can be found here: http://blog.radioactiveyak.com/2011/02/strategies-for-honeycomb-and-backwards.html

like image 165
Reto Meier Avatar answered Oct 03 '22 19:10

Reto Meier