Android Support Library for 4+ devices? - android

Do you think is it a good practice to use Android Support Library if my app will support only devices which working on Android 4 ? Or it is unnecessary?
Alex. P.S. Sorry for my English:)

The Android Support package is not only for backports. For example, if you want to use ViewPager, you will need to use the Android Support package. And, in 2014, the Android Support package might get backports of things that are not in whatever your planned android:minSdkVersion is.
If, instead, you are asking whether it is necessary to use FragmentActivity, the AppCompat action bar, and similar backports, no, you will not need those.

Use the support library only if functions you want to use don't work on one of the API levels you target.

Related

Android supportability and incompatibility is so unclear

what is the version of android from which further on there is no concept of incompatibility(no need of support libs). I am a newbie and this supporting and non supporting thing is making it so boring. I just want to know of a stable version from which I should take start and do not use support libraries (like appcompat, sherlock, etc). Also tell me if I am doing a wrong thing doing this I mean anything that will help me. Thanks
Any relevant help is appreciated.
As an app developer, you'd like your app to run on as many devices as possible. Generally, developers give support from API level 8 (Android 2.2) and upwards.
Most of the compatibility libraries are for pre-API 11 (HoneyComb).
So basically, it depends upon what you want to aim for.
Edit
You might be interested in checking out Choosing the right API Level for my android application.

Android Apps: How to tell whether I use Support-Lib or nor

I am new to Android development and I am following the training at http://developer.android.com to get into it. I am confused whether I do use the support library or not.
To make it clear: I do not need to support APIs older than 11.
Situation: Adding Items to the ActionBar I had to use my own Namespace to make it work (app:showAsAction="ifRoom" instead of android:showAsAction="ifRoom"), which is a normal behaviour using the support-lib, am I right?
First Question: Why am I using it? I did never activate it on purpose!
Second Question:
Is it normal that I can use both getActionBar().setDisplayHomeAsUpEnabled(true); and getSupportActionBar().setDisplayHomeAsUpEnabled(true); to make the "up"-functionality work? I thought the first one wouldn't work if I used the support-lib?
I'd be glad if one of you could help me. I don't want to mess around with these basics so I'd like to know what I understood or configured wrong.
EDIT: My "uses-sdk" in the AndroidManifest actually looks like this:
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19" />
To answer your first question, depending on how you created your project in the first place, it was probably enabled for you automatically. There are lots of other things in the support library besides ActionBar, so even if your minSdkVersion=11, it's probably still a good idea to use it.
To answer your second question, yes, it's normal that both methods work. Framework methods are not disabled or removed when you enable the support library. They will still work as long as they are supported by the Android OS you're eventually running on. For example, if your minSdkVersion was 10 instead of 11 and you tried to run the app on a device running Gingerbread, it would crash on the getActionBar() call.
In your case, you should use the framework method (getActionBar()). The documentation for ActionBar says:
This class is included in the support library for compatibility with
API level 7 and higher. If you're developing your app for API level 11
and higher only, you should instead use the framework ActionBar
class.
The best way to know whether you need to use the support library for a given method or class is to refer to the documentation for that class and pay attention to the "Added in API Level ?" notation. Here is the documentation non-support-library version of ActionBar, where you can see that some methods were added after API 11. If you need any of those methods, you should use the support library.
Also, as I said before, there other things besides ActionBar to consider in your app. GridLayout is an example. It was added in API 14, but it also exists in the support library for backwards compatibility. If you want to use GridLayout, you should use the support library version of it.

Android support library, when to use?

I was wondering, lets assume I want to develope some android app and I need new API specifics but supporting some older versions aswell. The question is: do I build everything with support lib or do I check for sdk version everytime and according to this I run selected piece of code?
Best regards,
Robert
If all the functionality that you need is available in support library, I would go for support library.
It will simplify your code, layouts, etc. a lot if you won't have to check for API version all the time. This means maintenance of your code will be much easier and number of bugs should also be lower.
Support library classes and usage are very similar to the actual classes so when you decide to drop support for older Android versions later on, the job of removing the support library will be fairly easy.

Usage of android.support.v4.app or android.app for DialogFragment?

Reading through official documentation of Android made me little bit confused about this 2 libraries. When should I use one and when the other one?
As far as I'm understanding, it's the best to use Android Support library depending to the number of devices that will be able to run it and the look will stay always the same. No matter what might get in the future of the android, Support library will always be supported on any future Android API. But why is then DialogFragment for android.app? It is logic to me that android.app.DialogFragment has some benefits which that from support's doesn't because anyways it would be useless to have it, since it's not supported on so many devices.
Can you help me which I should prefer to use it and if my sayings were right?
If your app needs to be compatible with Android 2.x you should use the DialogFragment from the Support Library. Notice that adding the Support Library to your project makes your app bigger because the JAR of the Support Library will be included in your APK.
If you only support Android 3.x or higher you can stick with the DialogFragment built-in into the OS.
Both versions of the API offer (roughly) the same functionality.

Implementing recently introduced Android design and UI guidelines on 2.x versions

Considering Android Design Guidelines announcement what is the best way to make apps which are compliant with them on Android 2.x phones? E.g. what is the best way to implement the ActionBar pattern?
ActionbarSherlock is a starting point. It includes the compatibility libraries from Google and comes provided as a project rather than JAR offering greater flexibility, should you need to alter anything. Version 4 is on the way which will also include ICS stuff.
As far as I am aware I believe ABS is backward compatible to 1.6, and makes use of the minSdkVersion and targetSdkVersion. It uses an extended version of the holo theme to create a light and dark version that includes the extra ActionBar goodness, which in turn you can extend to style your app.
I recorded a tutorial on YouTube to get people started.
I think it's better to use the compatibilty libraries directly, instead of another library based on those. Additionally, refer to the Google I/O App as stated at the bottom of the first link I gave. You can find the best practices about implementing a UI for several devices with compatibility libraries.
I found ActionBarSherlock to be pretty good. It will emulate ActionBar on older devices and use the native one on modern ones. It's an extension to Android compatibility library - so you will also get fragments and other ICS stuff.

Categories

Resources