Building a library that uses an optional library - android

I have an Android library that helps implement and add various GUI components the Android navigation drawer.
Currently the library will only support the full APIs from the supported API, i.e. from Honeycomb onwards.
I want to change the library so it can also work with AppCompat, that shouldn't be a problem as it is likely to always to be installed and available.
The problem I have, a couple of users who use the library have requested that my library can support the use of the ActionBarSherlock library as well.
I don't want to do to separate navigation drawer management libraryies, and app compat and then a separate library for ActionBarSherlock so what I am wondering is if there is a way I can make a class that uses ActionBarSherlock libraries but will only attempt to compile/use the classes(s) if ActionBarSherlock is available.
Therefore the user can use my one library and be able to use all 3 different types of navigation drawer without needing multiple different libraries to support them.
My library is used within Android Studio not Eclipse

Related

Doing an Android sliding drawer without the support APIs

I'd like to add a sliding drawer to my app which is using the min sdk version of 16 and a target sdk of 21 and should allow it to use the most recent features of the platform.
I looked around on how to implement a sliding drawer, and all the articles I found talk about using some support APIs to do just that.
My app is not yet using these support APIs.
I wonder if implementing the sliding drawer is possible without any support APIs, and if so, if there is any resources showing just that.
DrawerLayout, the basis for Creating a Navigation Drawer is only found in the Android Support Library (along with many other Support Library only APIs). There is nothing in the Android framework that provides this same functionality.
To provide the most consistent experience to users, you should just use the Support Library.
You should consider using support APIs, but if you really dont want to, you can use user-created library.
Here's one I used for one of my projects:
https://github.com/mikepenz/MaterialDrawer
Yes, it is always possible. However, the DrawerLayout class is available only in support libraries.
When I first realized that, it made no sense to me. But now I see support libraries as an extension of the core libraries (android.*).
Anyway, I recommend using the support libraries or you will have to create the logic to do exactly the same from scratch.
You can use android design support library, it's working on all devices in android and it's open source so you can edit it as you like with custom element.
Here's a reference how to implement Navigation drawer using new android support library

Does the Android Support Library default to the native libraries on the latest Android Version?

When starting any Android project, a developer has to choose between using the support library or the native library.
What happens when the support library is used on Lollipop? If I use the ToolBar support library object, and it runs on a Lollipop device, does the library default to the native implementation of the Toolbar automatically?
I am assuming that the native library is more efficient than the support library.
EDIT: referring to Toolbar now as an example instead of RecyclerView
What happens when the support library is used on Lollipop? If I use the ToolBar support library object, and it runs on a Lollipop device, does the library default to the native implementation of the Toolbar automatically?
No, it does not, as you can tell by looking at the source code for the backported Toolbar. Nothing in the current appcompat-v7 artifact will delegate to a native implementation.
The Android Support Package is vast, and different things will behave differently. The best rule of thumb is for Java classes that end in Compat (e.g., NotificationCompat), the class will delegate to a native implementation where possible, based upon API level, and will either implement a backport or simply "no-op" the request where a native implementation does not exist. And, despite the name, AppCompat is not a Java class, which is why it still complies with this rule of thumb. :-)
I am assuming that the native library is more efficient than the support library.
Not for most definitions of the word "efficient". It will save APK size. In terms of speed and memory consumption, there is unlikely to be any significant difference.
When starting any Android project, a developer has to choose between using the support library or the native library.
As noted, the "support library" is vast, and apps may well use a mix of things in the Android Support Package and things that are not. For example, apps may use NotificationCompat (e.g., to improve support for Android Wear and Android 5.0 lockscreen notifications) while using the native action bar and fragments.

How to implement android navigation drawer?

I want to implement the android navigation drawer for my app that is supporting jellybean and higher. All tutorials I seen so far use the support version.
I am wondering, are they doing that to support people who want to support old android versions?
If possible I want to use the non-support version. Does anyone know where I can find a good tutorial for that?
Or is using the support version the only way to get it?
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
Thanks
The docs for the Support Library states:
The Android Support Library package is a set of code libraries that
provide backward-compatible versions of Android framework APIs as well
as features that are only available through the library APIs.
This means that this library contains components, which are not included in the Android SDK. F.e. the ViewPager and related classes like the family of PagerAdapters or even the DrawerLayout.

"The type TabActivity is deprecated" For app tab

"The type TabActivity is deprecated"?
I am making the Tabs of app following tutorial book.
I've checked from the android developer.com website, but i have no ideas on the significance of the following message : This class is deprecated.
New applications should use Fragments instead of this class; to continue to run on older devices, you can use the v4 support library which provides a version of the Fragment API that is compatible down to DONUT."* (http://developer.android.com/reference/android/app/TabActivity.html)
What is v4 support library?
How to finish the tab functions?
You can still use a deprecated package. It is however recommended to use Fragments, and thus the support package. You can read more about it here. However, if you are a beginner at java and android development, I would recommend ignoring the deprecation for now and come back to this when you have completed the tutorial you are currently using if you find it educating.
If you want to watch a nice example of tabbed navigation using Fragments, then create a new project in Eclipse using android 4.0 or later. Make sure your android-plugin is updated. You will get the option to create a project with basic navigation already implemented.
"Deprecated" means that the api developers don't recommend using it anymore, probably because its not a good model, or inefficient, etc. Fragments were introduced in Honeycomb and can be used to provide a similar functionality as tabs and is more in-line with android's current design philosophy.
Since Fragment was introduced in Android 3.0 Honeycomb, you might think you cannot use that for pre-Honeycomb devices. Enter Support Libraries. They are libraries which you can include in your application which needs to run on pre-Honeycomb and still use this class.
So if you want to, you can finish the TabActivity as described in whatever tutorial you are following, it'll probably work on a few more upcoming android versions. But it is recommended that you start using Fragments.

ViewPager with indicator without Android's support library

Right now I'm using the ViewPagerIndicator for swipe-able fragments with an indicator in my program and it's working like a charm. But since Google is pushing more and more into the direction of Fragments without using the Android support library and e.g. PreferenceFragments aren't available in the support library, I'm wondering if there is something similar to the ViewPagerIndicator that's using the standard Android library.
Google is pushing more and more into the direction of Fragments without using the Android support library
And your proof of this is... what, exactly?
e.g. PreferenceFragments aren't available in the support library
It is not possible to backport PreferenceFragment very easily, as there are many other requirements to make that useful (e.g., backporting the new PreferenceActvity). I have personally looked into backporting the preference fragment system and concluded that it would be significantly more pain than it is worth to me.
I'm wondering if there is something similar to the ViewPageIndicator that's using the standard Android library
By definition, that is impossible, as ViewPager is in the Android Support package, which means any indicator for ViewPager must use the Android Support package.
However, there is nothing about ViewPager that requires you to use fragments. You are welcome to create your own PagerAdapter implementation that does not use any fragments, or uses native API Level 11 fragments, if you so choose.

Categories

Resources