2011年4月23日土曜日

Android ビルドバージョンで処理を分岐する

Build.VERSION クラスで端末のビルドバージョンを取得することができます。

Build.VERSION.SDK_INT には、フレームワークの SDK バージョンが数値ではいっています。この数値は Build.VERSION_CODES で定数として定義されているので、比較することで任意のビルドバージョンで処理をわけることができます。


if(Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) {

// 2.3.3 向けの処理


} else {

 // 2.3.3 以外向けの処理

}



if(Integer.parseInt(Build.VERSION.SDK) == Build.VERSION_CODES.CUPCAKE) {
// for 1.5
}
else {
switch(Build.VERSION.SDK_INT) {
case Build.VERSION_CODES.DONUT:
// for 1.6
break;
case Build.VERSION_CODES.ECLAIR_MR1:
// for 2.1
break;
case Build.VERSION_CODES.FROYO:
// for 2.2
break;
case Build.VERSION_CODES.GINGERBREAD:
// for 2.3
break;
case Build.VERSION_CODES.GINGERBREAD_MR1:
// for 2.3.3
break;
case Build.VERSION_CODES.HONEYCOMB:
// for 3.0
break;
default:
break;
}
}



・ 主な Build.VERSION_CODES の定数

 CUPCAKE
   May 2009: Android 1.5

 DONUT
   September 2009: Android 1.6

 ECLAIR
   November 2009: Android 2.0

 ECLAIR_0_1
   December 2009: Android 2.0.1

 ECLAIR_MR1
   January 2010: Android 2.1

 FROYO
   June 2010: Android 2.2

 GINGERBREAD
   November 2010: Android 2.3

 GINGERBREAD_MR1
   Almost newest version of Android, version 2.3.3

 HONEYCOMB
   Newest version of Android, version 3.0


# Build.VERSION.SDK に数字以外の文字列が入ると
# NumberFormatException になります。
# 安全なコードにしたいなら、try-catch するか、
# if(Build.VERSION.SDK.equals(String.valueOf(Build.VERSION_CODES.CUPCAKE)))
# なのかなぁ。
# ちなみに、Android Developers Blog: How to have your (Cup)cake and eat it too
# では、parseInt() 使ってました。

  

97 件のコメント:

  1. toptan iç giyim tercih etmenizin sebebi kaliteyi ucuza satın alabilmektir. Ürünler yine orjinaldir ve size sorun yaşatmaz. Yine de bilinen tekstil markalarını tercih etmelisiniz.

    Digitürk başvuru güncel adresine hoşgeldiniz. Hemen başvuru yaparsanız anında kurulum yapmaktayız.

    tutku iç giyim Türkiye'nin önde gelen iç giyim markalarından birisi olmasının yanı sıra en çok satan markalardan birisidir. Ürünleri hem çok kalitelidir hem de pamuk kullanımı daha fazladır.

    nbb sütyen hem kaliteli hem de uygun fiyatlı sütyenler üretmektedir. Sütyene ek olarak sütyen takımı ve jartiyer gibi ürünleri de mevcuttur. Özellikle Avrupa ve Orta Doğu'da çokça tercih edilmektedir.

    yeni inci sütyen kaliteyi ucuz olarak sizlere ulaştırmaktadır. Çok çeşitli sütyen varyantları mevcuttur. iç giyime damga vuran markalardan biridir ve genellikle Avrupa'da ismi sıklıkla duyulur.

    iç giyim ürünlerine her zaman dikkat etmemiz gerekmektedir. Üretimde kullanılan malzemelerin kullanım oranları, kumaşın esnekliği, çekmezlik testi gibi birçok unsuru aynı anda değerlendirerek seçim yapmalıyız.

    iç giyim bayanların erkeklere göre daha dikkatli oldukları bir alandır. Erkeklere göre daha özenli ve daha seçici davranırlar. Biliyorlar ki iç giyimde kullandıkları şeyler kafalarındaki ve ruhlarındaki özellikleri dışa vururlar.

    返信削除
  2. beğeni satın al
    instagram takipçi satın al
    ucuz takipçi
    takipçi satın al
    https://takipcikenti.com
    https://ucsatinal.org
    instagram takipçi satın al
    https://perdemodelleri.org
    https://yazanadam.com
    instagram takipçi satın al
    balon perdeler
    petek üstü perde
    mutfak tül modelleri
    kısa perde modelleri
    fon perde modelleri
    tül perde modelleri
    https://atakanmedya.com
    https://fatihmedya.com
    https://smmpaketleri.com
    https://takipcialdim.com
    https://yazanadam.com
    yasaklı sitelere giriş
    aşk kitapları
    yabancı şarkılar
    sigorta sorgula
    https://cozumlec.com
    word indir ücretsiz
    tiktok jeton hilesi

    返信削除
  3. On your place I would make a video about this build version and publish it on youtube. If you want to lead youtube channel all the time use this site https://soclikes.com/ to get subscribers for your channel

    返信削除
  4. ビデオを作成してtiktokに投稿したい場合は、私はあなたにアドバイスしますTiktokの「いいね」の購入。

    返信削除
  5. All kittens adopted from royaltykitten.com Sphynx Cattery come with current vaccinations, dewormings, written sales contract, Two year health guarantee, health record, Spayed or Neutered, 30 days of free pet insurance for your kitten,
    sphynx cats for sale, sphynx kittens for sale, hairless kitten for sale, hairless cats for sale, and a kitten care package which includes food, litter and several surprises for you and your kitten. sphynx cat for sale near me, sphynx kitten for sale, hairless cats for sale near me, hairless kitten for sale, hairless cats for sale Kittens are Generally ready to leave between 10 to 11 weeks old.
    Sphynx do not develop as quickly as cats with hair.

    返信削除
  6. If you are looking for a new furry friend, british shorthair kitten may be a perfect choice. british shorthair for sale near me have been around since the 1800s and were originally bred in England to hunt rats. These days they are more likely found as pets than on the job, but their hunting instincts still remain strong!  british shorthair cat for sale can come in many different colors so no matter what your preference is you will find a British Shorthair that matches it perfectly.

    返信削除
  7. Beagle puppies are one of the most popular breeds in the world. Beagle Puppies For Sale are intelligent, friendly, and loyal dogs that make great companions for people with allergies or who live alone. Beagles have a single coat that is short and soft to the touch, which makes them perfect for active city dwellers who want an outdoor companion. Beagle puppy are usually available at shelters because they're so popular! If you're looking to adopt a Beagle puppies For Sale near me, check out your local shelter today!

    返信削除
  8. This is very interesting, You are a very skilled blogger.
    토토사이트
    경마사이트
    경마

    返信削除
  9. I have joined your feed and look forward to
    seeking more of your magnificent post. Also, I’ve shared your site in my social networks!
    바카라사이트
    토토

    返信削除
  10. I am overwhelmed by your post with such a nice topic. Feel free to visit my website, thank you! 토토

    返信削除
  11. It is really a great and helpful piece of info. I am glad that you shared this helpful information with us. Please keep us updated. Feel free to visit my website, thank you! 카지노사이트

    返信削除
  12. The beauty of the words is that the same words can be used in a variety of ways to provide a different and unique meaning. You possess the nice and quite impressive style of writings that has touched my heart and soul. I shall come again to soothe my knowledge and skills thirst. Feel free to visit my website, thank you! 파워볼사이트

    返信削除
  13. I am sure this piece of writing has touched all the internet users, its really really fastidious piece of writing on building up new weblog. Feel free to visit my website, thank you! 바카라사이트

    返信削除
  14. Thanks for such a valuable post. I am waiting for your next post, I have enjoyed a lot reading this post keep it up.
    바카라사이트

    返信削除
  15. This is really helpful post and very informative there is no doubt about it.
    온라인카지노

    返信削除
  16. Thank you for sharing this information. I read your blog and I can't stop my self to read your full blog. Again Thanks and Best of luck to your next Blog in future.스포츠토토

    返信削除
  17. I really enjoy your web’s topic. Very creative and friendly for users. Definitely bookmark this and follow it everyday.
    카지노사이트

    返信削除
  18. I love what you guys are usually up too. This sort of clever work and coverage! Keep up the excellent works guys I’ve you guys to my own blogroll.
    ragdoll kittens for sale near me


    Hi, of course this piece of writing is actually fastidious and I have learned lot
    of things from it concerning blogging. thanks.
    ragdoll kitten near me

    https://thegorgeousdoodles.com/
    https://www.fluffyhavanese.com/
    https://www.pomeranianpuppiesforsales.com/
    https://thegorgeousragdolls.com/

    返信削除
  19. At this time I am going away to do my breakfast, afterward having my breakfast coming over again to read further news
    ragdoll cat for sale


    Usually I don’t read post on blogs, but I wish to say that this write-up very compelled me to try and do it!
    Your writing taste has been surprised me. Thank you, very nice article.
    ragdoll cats for sale

    Hi, I do think this is a great blog. I stumbledupon it �� I may come back once again since I saved as a favorite it.
    Money and freedom is the greatest way to change, may you be rich and continue
    to guide others.
    aussiedoodle for sale

    Wonderful article! That is the kind of info that are supposed to be shared around the net.
    Shame on the seek engines for now not positioning this publish upper!
    Come on over and discuss with my website . Thank
    you =)
    bernedoodles for sale

    What’s Going down i’m new to this, I stumbled upon this I have found It positively useful and it has aided me out loads.
    I hope to give a contribution & help different users like its aided me.
    Good job.
    goldendoodle for sale

    返信削除
  20. Generally I don’t learn post on blogs, but I would like
    to say that this write-up very pressured me to try and do so!
    Your writing taste has been surprised me. Thanks, quite
    great article.
    ragdoll kitten for sale


    whoah this blog is excellent i love studying your articles.
    Keep up the good work! You recognize, lots of individuals are looking around for thisinfo, you could help them greatly.
    ragdoll kittens for sale


    Good post. I certainly love this website.
    Continue the good work!
    mini goldendoodle for sale

    Hey! I’m at work browsing your blog from my new iphone
    3gs! Just wanted to say I love reading through your blog
    and look forward to all your posts! Keep up the outstanding work!
    mini bernedoodle puppies for sale

    I’m new to the blog world but I’m trying to get started and create my own. Do you need any html coding
    expertise to make your own blog? Any help would be really appreciated!
    mini aussiedoodles for sale

    返信削除
  21. Hey! are using WordPress for your blog platform?

    I’m new to the blog world but I’m trying to get started and create my own. Do you need any html coding
    expertise to make your own blog? Any help would be really appreciated!
    doodle puppies


    Thank you for the good writeup. It in reality was a enjoyment account it.

    Look complicated to far introduced agreeable from you!
    By the way, how could we communicate?
    aussiedoodle puppies for sale


    Good post. I certainly love this website.
    Continue the good work!
    bernedoodle puppies for sale


    Hey! I’m at work browsing your blog from my new iphone
    3gs! Just wanted to say I love reading through your blog
    and look forward to all your posts! Keep up the outstanding work!
    goldendoodle puppies for sale

    返信削除
  22. Thanks for sharing your thoughts. I truly appreciate your efforts and I will be waiting for your further
    write ups thanks once again
    pomeranian puppies for sales


    This information is invaluable. Where can I find out more?
    pomeranian for sale


    This is the right webpage for anyone who hopes to understand this topic.
    You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa).
    You definitely put a fresh spin on a topic that’s been discussed for a long
    time. Great stuff, just excellent!
    teacup pomeranian for sale near me


    It’s amazing to pay a quick visit this website and
    reading the views of all colleagues concerning this article,
    while I am also zealous of getting familiarity.
    pomeranians for sale near me


    I take pleasure in, result in I discovered exactly what I used to be taking a look
    for. You’ve ended my 4 day lengthy hunt! God Bless you man. Have a nice
    day. Bye
    pomeranian teacup for sale

    返信削除
  23. Ahaa, its nice dialogue about this piece of writing at this place at this webpage,
    I have read all that, so at this time me also commenting here.
    havanese dogs for sale

    Hi, I do believe this is a great website. I stumbledupon it ;) I am going to revisit yet
    again since I book-marked it. Money and freedom is the greatest way to
    change, may you be rich and continue to help other people.
    havanese puppies for sale


    I used to be suggested this website by means of my cousin. I’m now not sure whether
    this submit is written by him as nobody else know such detailed approximately my problem.
    You’re incredible! Thanks!
    teacup havanese puppy


    Hi my family member! I want to say that this
    post is awesome, nice written and include almost all
    important infos. I’d like to peer more posts like this
    chocolate havanese puppy for sale


    Hello, constantly i used to check blog posts here early in the
    daylight, since i like to find out more and more.
    havanese puppy for sale

    返信削除
  24. I think your website has a lot of useful knowledge. I'm so thankful for this website.
    I hope that you continue to share a lot of knowledge.
    This is my website.

    머니상

    返信削除
  25. There's nothing perfect in this world.
    I'm so excited. I won't do anything foolish to dream of a perfect world.
    There are a lot of good comments on my website, so please visit.
    This is my website.
    41game.net

    返信削除
  26. When did you start writing articles related to ? To write a post by reinterpreting the 메이저사이트추천 I used to know is amazing. I want to talk more closely about , can you give me a message?

    返信削除
  27. I think your website has a lot of useful knowledge. I'm so thankful for this website.
    I hope that you continue to share a lot of knowledge.
    This is my website.
    한게임머니상

    返信削除
  28. Thanks a lot. Your blog made my day. A Turkish tourist visa is a necessary travel document to visit Turkey. If you are planning to visit Turkey please know a bit about the Turkish visa.

    返信削除
  29. It’s actually great and useful information. Thank you for sharing this useful information with us. 스포츠토토

    返信削除
  30. Thanks for sharing a nice article really such a wonderful site you have done a great job once more thanks a lot 온라인경마

    返信削除
  31. Thanks for sharing such great information. It was really helpful to me. 릴게임

    返信削除
  32. It is really a great and helpful piece of information. 토토

    返信削除
  33. This is one very interesting post. I like the way you write and I will bookmark your blog to my favorites. 바카라사이트

    返信削除
  34. What an awesome post, I just read it from start to end your blog post. Really an informative blog. 바카라사이트

    返信削除
  35. Thank you for sharing this useful article , and this design blog simple and user friendly regards. 바둑이게임

    返信削除
  36. The information provided by you is really very good and helpful for me. Keep sharing good information. 바카라사이트

    返信削除
  37. Hi there, You have done an excellent job. I will certainly digg it and personally suggest to my friends. I am confident they will be benefited from this web site. Feel free to visit my website; 바카라사이트

    返信削除
  38. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing. Feel free to visit my website; 바카라사이트닷컴

    返信削除
  39. In my opinion, the item you posted is perfect for being selected as the best item of the year. You seem to be a genius to combine 안전놀이터 and . Please think of more new items in the future!

    返信削除
  40. Thanks for such a fantastic blog. Where else could anyone get that kind of info written in such a perfect way? I have a presentation that I am presently writhing on, and I have been on the look out for such great information. 먹튀검증사이트

    返信削除
  41. spins. Almost every game is free spins. Let's get to know betflix

    返信削除
  42. This is very well written information. I am sure anyone using it will benefit from it. Keep it up! You can get Indian visa online easily.

    返信削除