开发者

Support 3.0 and lower levels in the same project

  1. I have a level 9 app on android, and I want to know if I can use new features from level 11 (Android 3.0) in the same project?
  2. For 3.0 tablet version, my layouts will contain fragments. How do I use these fragments and allow the level 9 version to build and run successfully开发者_运维百科?
  3. Can I define different layouts for different API levels (in the res/layout)?
  4. If I keep 2 versions, one for tablet other for phones, can I add that to the android-marketplace with the same package name?


I have a level 9 app on android, and I want to know if I can use new features from level 11 (Android 3.0) in the same project?

Yes, via reflection or conditional class loading, as suggested by Mr. Willis. Here is a sample application that demonstrates this for the action bar, also new to API Level 11.

For 3.0 tablet version, my layouts will contain fragments. How do I use these fragments and allow the level 9 version to build and run successfully?

Use the Android compatibility library.

Can I define different layouts for different API levels (in the res/layout)?

Yes, via the -vNN resource set suffix (e.g., res/layout-v11). However, you should try to minimize this.

If I keep 2 versions, one for tablet other for phones, can I add that to the android-marketplace with the same package name?

No.


This question and answers seem helpful.

The official documentation also overs solutions in Backward Compatibility for Applications.

Try: http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html

Using reflection is advised, which allows you to programmatically search for the existence of classes and methods at runtime.

As for layouts, try checking out Supporting Multiple Screen Sizes. There are different layout sizes such as layout-xlarge that you can use.

If I keep 2 versions, one for tablet other for phones, can I add that to the android-marketplace with the same package name?

You can't use the same package name for two different apps.

If your code is sufficiently different depending on the API version you're using, you might want to fork your code and then merge it again later when you are confident most of your user base has upgraded to the API level you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜