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
and add some tags to support multiple screens:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="9"/>
<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
Related
As stated in my question, I am going to develop an app to be published on Google Play, and that app will properly support phones and tablets.
This means the phone and tablet apps will share pretty much the same features, but will display possibily very different layouts in order to offer the best UX for these respective platforms.
At this point, I wanted to go about as following and was wondering if that was the correct way:
I believe App Bundles will help me achieve that, so let's assume I create a new Android Studio project from scratch.
Then, using File > New > New Module, which opens the module creation dialog, I would generate two Phone * Tablet Module and one Android Library module, a module that will contain all the shared same business logic, common to both aforementionned modules.
Then, using the Manifest, I would add the restriction to target phones and tablets separately.
I believe both app modules will need to have the same package name (application id).
Would that be the correct way ? Am I missing anything ? Is there a better standardized way to do so ?
Thanks for the help !
You only really want the layout to change, right? So just create different layouts for the different devices, you can add the qualifiers on creating a new layout file.
https://developer.android.com/training/multiscreen/screensizes
Check this for further information.
I have an app and that's already been made for large devices i.e 10 inch tablets and kiosk. I made the same design for the mobile phones but that was not looking good ,so I thought to move the mobile device to material design and the rest of the devices (tablets & kiosk) would remain same.
I know how can I make different layouts for the different devices i.e normal , large and x-large but I am worried about the code. So basically followings are my confusions....
What is a best way to Judge which device my app is running on in code so that I have to run some methods on the basis of that because my normal device is following material design and contains some widgets that are not present in the design of tablets and kiosk i.e RecyclerView (for some purpose)?
I have searched a lot for this problem and came to a point that there are 2 ways of supporting multiple devices
1> make two separate apks , 2> Make one apk and check in code to differentiate the devices, but as i said above in point no#1 that i have material design in normal devices and that is completely changed design in terms of widgets and layouts , fragments and even navigation, so what would you suggest is the best way to handle this?
If I make 1 apk and put a check in code , then I must say I have a ton of code , and resources and in either case (if the device is normal and large) some resources and classes will never gonna used and will make apk size larger so what is a best way to make a work around about this problem ?
I have also searched through stackOverflow and only came up with these two links that were close to my question but rest of the links are about different layouts not the code:
Android app for phone and tablet: 1 or 2 apps?
Creating different layout for android phone and tablet
I hope I am quiet clear in my question please answer my these question with some authentic reasons and links.
Multiple apks for a single app is supported in Google Play. However, unless your app is very large (greater than 100MB) they recommend you release one apk for all devices.
So you need to inspect the screen size at run-time. You can do this by category, by device independent pixels, or even in inches. Then, as you said, you would load the appropriate layouts and fragments accordingly.
Even if you were to use different apks, you would likely do it in a similar fashion because you probably want to share SOME code.
In Gradle you would make productFlavors for each apk, along with a variable to define the build like this:
productFlavors {
bigtablet {
buildConfigField "String", "deviceType", "\"bigtable\""
}
smalltablet {
buildConfigField "String", "deviceType", "\"smalltable\""
}
}
Then at runtime you would use the BuildConfig.deviceType to drive the exact same logic as the screen size did in the one apk method. With this method Gradle will strip out all the unused code from each apk.
The last option would be create completely different projects for each apk. Pushing all the shared code into libraries.
You can always put it all in one apk for now and switch to multiple productFlavors if the apk grows too large. Since the logic is similar it wouldn't be too hard to swicth. Hope this helps.
The Support Libraries are designed to minimize the amount of work you need to do to detect differences in the Android version where your app runs. For example, RecyclerView is available in the Support Library. Between this and layout-xxx folders, you can usually build a single APK for all API levels and device form factors.
I created an application which has different layout for phones and tablets. Can I add my app in two apk on Google Play one for Phones & one for Tablets? I found supports-screens in the documentation but not sure about that. I have to do this because my app is dealing with images and if I merge images for both (phones & tablets) then size of app is very large.
Yes, you can target apks to specific device configurations. Here's the documentation on it: http://developer.android.com/guide/google/play/publishing/multiple-apks.html
Yes this is possible.
I'd recommend to set the name as:
"..." for phone
"... HD" for tablets
I'd also include a link in both descriptions, referring to eachother (so the phone app refers to the HD version and visa versa).
Also, i'd recommend to read this:
http://developer.android.com/guide/google/play/publishing/multiple-apks.html
Yes, you can have single app with multiple APKs. See Multiple APK support, but unless you really see the difference there like completely different assets which bloats the whole app, then sticking to single binary app helps maintaining it further
This question already has answers here:
multiple screen support in android [duplicate]
(4 answers)
Closed 1 year ago.
If I make an android app using android 2.3.3 and after completion i make it work for other devices, is this a good idea ? Because i have not developed app for multiple screen sizes. Would it be more time consuming ? What precautions I would have to take ?
The best place to start this kind of research is with Google's Android Development website, which has tons of helpful guides and resources. Here are two links which may help you with your problem:
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/training/multiscreen/screensizes.html
And another which discusses layouts. The Dev Guides have a bunch of mini-tutorials to teach you how to use and the differences between many views.
http://developer.android.com/guide/topics/ui/declaring-layout.html
On the whole, you should definitely start coding with multiple screen sizes in mind, although this goes along with just having good android coding practices. In general, get acquainted with the xml attributes that start with android:layout_ for example android:layout_width and android:layout_weight and the way your image resource folders need to be managed. In my experience, once you get comfortable with how layouts work on Android, making sure they work over multiple screens will come easily. Having a basic understand of it before get in too deep in will save you a lot of headache and recoding later. Don't be afraid to make simple apps to test different layout techniques you're learning. Good luck.
I think you should do more research from your part, but here is a link to get you started.
http://developer.android.com/training/basics/supporting-devices/screens.html
First decide on the minimum SDK version you are willing to support (let's say minSdkVersion="8" for example).
Second, build your application against Android 4.1 and set your targetSdkVersion="16". Doing so will allow you to make use of some of the prettier UI features (i.e. Holo themes) on newer devices.
Third, test your application extensively using the emulator on devices running SDK 8 through 16. If you make any method calls from the newer APIs, make sure you prevent older devices from invoking these methods (as they will not be recognized and will crash your app at runtime). At this point you can optimize your application for different screen sizes (i.e. phones and tablets).
I have a published app for Android 1.x and 2.x, and now I want to make it support 3.x.
But Android 3.0 has massive API change, especially on UI, thus if I want to make one app compatible to 2.x and 3.x, the code will be ugly and package file will be huge.
On the other hand, if I make another app for 3.x, then I need to maintain two copies of their common codes. That's really annoying.
What should I choose, or does anyone have a more smart solution? Thanks!
If you package them together you could still maintain everything separately - For example: put a prefix in front of every layout and class for 3.x, such as honeyMain.class, and honeymain.xml
Or you could do it a way that makes more sense for you.
Or keep them partially together.
It WILL make your app larger, but then when 15 people with 3.x download it and 60 people with 2.x download it, you get 75 downloads, instead of 15 for one app and 60 for the other. The 75 cumulative will look better on the apps over all ranking on the market.
On the other hand, if the 3.x is really ugly or FCs, then negative ratings will impact both 2.x and 3.x, but that is easily controlled for by testing, testing, testing.
Also, I personally hate managing code for two different apps. It's overly repetitive.
So, my recommendation is to package them together.
Make use of resource qualifiers, e.g. -xlarge, -v11, etc.
Use reflection where necessary or other techniques to avoid pulling in stuff not supported by API level.
Use the compatability library, that way you can fragmentize your code regardless, avoiding duplication, and with little effort handle different screen sizes.
See providing resources
See multple screens
See compat lib
Right click on your project and select "properties",select "android" from window,and which type of version you want check it and apply