Using new sdk methods on devices running older sdks?

by Mark Murphy » Tue, 22 Dec 2009 01:47:43 GMT

Sponsored Links

I wouldn't do:

if (Build.VERSION.SDK.equals("5")) {

Instead, parse it to an integer and do a >=5 comparison. After all, most
DROIDs are now on API 6 (i.e., Android 2.0.1). And, once you drop older
SDK support, you can use SDK_INT and skip the parse step.

If you are going to make the request a lot, you might consider having
your two implementations extend a common abstract class or implement a
common interface. Then, you can make the determination of which one to
use once and hold onto that object, calling it by the common interface
as needed.

Otherwise, the notion of "if I don't load the class, there will be no
harm in it referencing newer API capabilities" is sound.

Mark Murphy (a Commons Guy)  | 

_The Busy Coder's Guide to Android Development_ Version 2.8


Other Threads

1. background.png adding to a snake game

Hi All,
 I am trying to learn android application development. For start I am
trying to modify the snake game which is given in SDK samples. Could
you please tell me how to change the background of snake game through
code. I want to insert my image instead of black color background.
Please tell me how to go ahead.

Warm regards,


2. Android Functional Testing (testing multiple activities)

I've been exploring the Android test package and I'm very confused on
how to implement functional testing for endpoint-to-endpoint.

Consider the example below, I have 4 activities:
1. A Contact List Activity
2. A View Contact Activity
3. An Add/Edit Contact Activity
4. A Sync Contact List activity

I want to automate a few tests that will go through multiple test
cases simulating a user experience:
the add contact activity,
entering data, saving it, going back to the list activity, and
verifying the new contact was saved properly.

As I understand it, ActivityInstrumentationTestCase<T extends
Activity> and ActivityUnitTestCase<T extends Activity>, are only
useful for testing single activity functionality.

But what if I need to switch between 2 or more activities inside a
single functional test case?

Any help would be greatly appreciated.


3. Activity onPause method

4. problems with bitmaps

5. Cant see paid apps in US

6. New SDK 1.5 issue

7. How to publish application to own device without Android Market?