1

I am going through the Google Cloud Services tutorial here: http://developer.android.com/guide/google/gcm/gs.html

And they suggest that I place this line in my manifest:

And I currently have this line because I want to support as many devices as possible:

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>

What I am not sure is how I can still support as many devices as possible but when a push needs to happen to an older version phone, I am ok with it just simply not delivering the message.

So my question is what should my line read there? Also, is SDK version up to 20 now? Should I change that too? :)

Genadinik
  • 18,153
  • 63
  • 185
  • 284

1 Answers1

4

It requires version 8 (Android 2.2) or any newer versions. Most of the android devides use 2.3 and higher so 2.2 is a good choice.

android:minSdkVersion="8"
n00b
  • 2,738
  • 2
  • 20
  • 31
  • but what happens if I leave it at 4? Will it not work for anyone? – Genadinik Oct 15 '12 at 20:15
  • You could leave it at 4 and wall off the cloud portions of code with version checks, but if your code relies on it, it would be easier to just use 8. API level 4 is only used on roughly 4% of the market these days. – Geobits Oct 15 '12 at 20:21
  • @Geobits yeah I am afraid if the existing users with old versions will upgrade and that will disable their app, they will give me bad reviews :) – Genadinik Oct 15 '12 at 20:23
  • If it is possible to have the push work only for people on version 8 and up that is totally ok with me as long as I can leave in the manifest that android:minSdkVersion="4" - and you are saying this is possible, right? – Genadinik Oct 15 '12 at 20:24
  • 1
    Yes, just make sure you check the API version in code. If it's lower than 8, don't execute that part. If you do, it'll crash out and you'll get even worse reviews. See here for API check: http://stackoverflow.com/questions/3423754/retrieving-android-api-version-programmatically – Geobits Oct 15 '12 at 20:26
  • @Geobits actually if it crashes, I can just catch that exception and the user will never know, right? :) It might be even easier just to silently crash than to rely on getting device information....what do you think? – Genadinik Oct 15 '12 at 20:31
  • Personally? I cringe at the idea. All you have to do is check the version once when the app starts up and save the value in a static variable. Surely it's better to surround it with an `if` than `try/catch`. I'd rather avoid exceptions than handle them. – Geobits Oct 15 '12 at 20:33
  • @Geobits I am just concerned that not all Android devices will give that information. By the way, what is this version called in their api? How do I actually check the version? :) – Genadinik Oct 15 '12 at 20:41
  • Check the link I gave a few comments up. The answer with 70+ votes. It works on API 4+. – Geobits Oct 15 '12 at 20:48