The AbsoluteLayout class is deprecated but still can write it in code and it works. Will there be any problems if I use this class? Will the application work correctly after I deploy it on a phone?
Thanks
Deprecated generally means that you are discouraged from using it because better methods exist. It can also serve as a warning that it will be removed entirely in future versions.
I would think you would want to stay away from absolute layouts because it can prevent your UI from scaling correctly on different resolutions, and it might not work at all on later versions of Android.
"will the application work correctly after I deploy it on a phone" most likely yes, but like I said you are probably going to run into issues with phones having different display resolutions.
This is a mighty assumption. It depends on the purpose, a business application on a standard large-screen device (tablet) may have a reason to go absolute.
Related
Will the property just not be expressed or could there be a crash? What is the best way to support older APIs with maybe separate layouts/themes?
Properties it doesn't understand are ignored. You can generally use them without a crash, although they won't have any effect and that could possibly cause other problems. You can provide version specific layouts if needed.
I realized that Gallery class in Android is deprecated, but I can still build my application and it runs correctly.
I don't care much about performance, since it will contain 2-3 pictures at most.
What I'm wondering is, is it safe to use Gallery ?
Will it work in all devices (including API > 16)?
And I hope that Android Dev Team replaces Gallery with another widget, instead of making us write our own galleries using HorizontalScrollView etc.
There are certain functionality deprecated by the Android Engineers just to make the developers use a newer implementation of the same. For example the Dialog Fragment requires a lot of coding to do the same task a showDialog() can possibly do. You are completely safe on this one as far as I know. At the same time, there are some other deprecation made due to security issues as well. In the case of Gallery, I understand that there is nothing wrong with using the deprecated class, except that it is deprecated. You are safe.
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'm planning on writing an app and building against 2.2 Froyo (API Level 8). However, I want app users of 4.0 ICS to experience the app with the ICS user interface.
Currently my approach is to have the default activity of my app sense the version of the Android device.
If it is less than 4.0, use XML views written for Gingerbread and Froyo and, if it's 4.0 or higher to use ICS XML views. This however seems a bit haphazard and I'm not sure I can manage the separation of version views effectively.
What approaches, tools, and ideas can I use to help me make my app? Is it even something I need to consider? Is my idea of the view separation above correct? Do I have alternatives I could use instead?
Cheers!
If you just want to apply different resources for different OS version, you can let system do it for you by putting your resources into different resource folders with the "v" qualifer. Such as "layout-v8" folder for layouts used for Froyo and "layout-v14" for layouts used for ICS. I did not try this but from the document, that's what it supposes to do.
The Crunchyroll app (an anime viewer) has separate activities and layouts for Froyo vs. Honeycomb/Google TV, defaults to one or the other on initial startup, and thereafter allows the user to declare a preference for one or the other. I'm not affiliated with CR, but I use and have studied the app. One problem the app has, which may be encouraged by the level of separation it has between the two targets, is that the pre-Honeycomb interface has many features, and continues to receive updates, that the tablet/TV interface is only promised.
As for tools, you can use later features while targeting an earlier OS with the SDK's support package, which backports features (e.g., fragments) appropriately.
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