On Tue, Dec 1, 2009 at 10:39 AM, Andrex <emailofand...@gmail.com> wrote:

> I'd say if you want to support as many handsets as possible, take
> pcm2a's advice and target 1.5. However if you really need to take
> advantage of new resolutions or you're not worried about download
> totals I'd say target 1.6 and wait for the other devices to catch up.
>

Just to reiterate -- there is really no reason not to build against the most
recent (2.0) SDK, as long as you test against the older ones.  Use
android:targetSdkVersion to tell the system that you have developed against
the newer version so they will be able to turn off their various
compatibility features.  There are numerous tricks you can do with Java to
use newer APIs if they exist while still working on older versions of the
platform.  For example, this code will allow you to use the new
Service.onStartCommand() callback while still working on older versions of
the platform:

    // This is the old onStart method that will be called on the pre-2.0
    // platform.  On 2.0 or later we override onStartCommand() so this
    // method will not be called.
    @Override
    public void onStart(Intent intent, int startId) {
        handleStart(intent, startId);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        handleStart(intent, startId);
        return START_STICKY;
    }

    void handleStart(Intent intent, int startId) {
        // do work

Of course if you want to make things absolutely as simple as possible, the
approach of just developing against the 1.5 SDK and only dealing with later
platforms as test targets is probably it.  This can be extremely limiting
however, since it makes it impossible to avoid compatibility modes like the
density scaling, or take advantage of any newer APIs (at least without just
raw use of reflection).

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to