开发者

Android app for phone and tablet: 1 or 2 apps?

开发者 https://www.devze.com 2023-04-05 14:53 出处:网络
I have to develop an application for both Android phones as tablets. The application logic is the same, while the UI is completely different.

I have to develop an application for both Android phones as tablets. The application logic is the same, while the UI is completely different. I'm wondering how I should deal with this: make 1 big app for both, or an app for phone and an app for tablet (and then upload the 2 apk's as 1 app in the market).

When I make 1 application, I should check if it's phone or tablet in code to redirect to the appropriate activity. Also I should include compatibility code to make it compile for phones. If I would make 开发者_开发百科2 apps, I don't need that check and I also don't need to include the compatibility code, so the app would be a lot smaller. But in that case I'll have to copy/paste the application logic constantly from one project to the other one while development.

So that's why I'm wondering, what's the best practice in this case? I've been searching for information about this, but I only find articles about how to manage the different xml layouts, or articles with not so much information in it.


My Answer, one app. The iosched - Google I/O App for Android demo example from Google I/O explains everthing about how and what. Source Code available! Worth trying it!

Apk Download Link : http://www.mediafire.com/?wck52jweyz1


Certainly make one application.

You can create different layout files for phones and tablets. For tablets you should create extra layout file in res folder which is called layout-large (for tablets), for phone which provides default layout file, and at the same time for landscape mode you can create one more folder named as layout-large-landscape (tablets) for phones layout-landscape

Android app for phone and tablet: 1 or 2 apps?

and add some tags to support multiple screens:

  1. <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="9"/>
  2. <supports-screens android:anyDensity="true" />


Certainly make one application.

Android is perfectly designed to be targeted to various devices, its automatic resource selection from res/ folders depending on device's capabilities is big help for you. You can have completely different screen layout for large screens vs small ones, for portrait vs landscape, for tablets vs phones, etc.

And your code is written/maintained just once.

Of course, you would make come conditional code depending on if your loaded layout has particular view, for example loaded only on large screen, and conditionally fill there additional data if its present.

Read documents on Android developer site about how to support multiple screens, multiple Android versions, compatibility modes with older Android versions, etc.

Also, if you ship just one app, you get single users' feedback / rating on Android Market, not in 2 separate apps.


I have been mulling over the same stuff, although i already have my code layouts split out for tablet / phone variants I am looking for size optimisation by using two apps, however I set out a method for using ONE code set to build both variants.

https://stackoverflow.com/questions/13956515/android-should-i-split-my-app-into-tablet-and-phone-variants

0

精彩评论

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