Android ParcelFileDescriptor.createPipe() for Froyo? - android

I have a need to use ParcelFileDescriptor.createPipe(), but I would still like to target API 8/Froyo. This function requires API 9/Gingerbread.
I have read that there are compatibility kits that allow newer API functions to be used on the older OS versions, but know nothing about them. Is that an option here?
If not, what would be the cleanest method for going about duplicating this functionality? I have considered using fromSocket() and making a simple network connection over the loopback interface, but that seems like more overhead than is needed, if there were a simpler way.
Any thoughts or advice would be much appreciated. I should also point out that I am using Monodroid, but a simple Java-based example that uses the Android API would be fine. I can translate it to C#.

Related

Using TLS in Android

I'm developing an Android application that communicates with my device(ARM based device with bluetooth module) via bluetooth using TLS(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256).
What I considered:
javax.net.ssl from Android. Problem is that ephemeral(ECDHE) encryption keys are starting from API 20 but I need API 11. I didn't find a way to add suite. It seems that this library is strongly related to android version. API versions and overview
Bouncycastle(spongycastle) I didn't find a way to use it without creating a socket. I need something like in/out streams so I could use it not with the network connection. Also I didn't find TLS/SSL at all.
Implementing everything by myself. I could take all algorithms from selected suite and implement protocol by myself but I don't know what I don't know and I'm afraid to screw up security. I don't know if it's a good practice to do such a thing(may be it's high level enough so it's not very dangerous to implement it by myself)
My question is: which libraries could you recommend for TLS? Is it a good way to implement the protocol(not algorithms) by myself?

Can we use EffectFactory Class for lower versions

For my new assignment, I wanted to use some library that can provide a "Posterize effect". I found many library like Aviary SDK and jhlabs, Yes, these are easy to use, but these making the code heavier. SO I keep searching for Android's API itself which can do the similar task. And after a lot of RnD, I finally found one my time saver class EffectsFactory which provides the same as I wanted. I applied it in my assignment also. But the bad thing it was added in API level 14, And my app should be compatible with at least API level 8.
So, My question is,
Can I use EffectsFactory class for lower version? If Yes then How?
Or, If No, Then Do we have any API in Android SDK itself which do similar to effectfactory ?
Please avoid referencing any library or NDK's open cv library.
No, there is not an Android API that will posterize an image below API 14. Even above API 14 EffectsFactory may not work, as it says in the Android documentation:
Some effects may not be available on all platforms, so before creating a certain effect, the application should confirm that the effect is supported on this platform by calling isEffectSupported(String).
However, you could easily make a lightweight solution yourself. Posterization is a simple process. For example, the code behind JHlabs' posterize filter is less than 50 lines (and most of them are sugar). In your shoes, if using a 3rd party library was out of the question, I wouldn't hesitate to write my own.
Edit: If you happen to be posterizing images your app takes from the camera, there is also Camera.Parameters.setColorEffect(), but again this is not supported on all devices, as it says in the documentation:
For example, the application should call getSupportedColorEffects() before calling setColorEffect(String).

Backwards compatibility in Android

I need to call a method in Android SDK v9 while maintaining compatibility with older versions.
The Android developer blog recommends using reflection or wrapper classes, but is that all really necessary? Why can't I just do this?
if (Build.VERSION.SDK_INT >= 9)
callNewMethod();
It seems to me this will work due to Java runtime linkage, since I am building with SDK 9. Is there anything wrong with this approach?
Thanks in advance...
No not at all. Actually it is promoted as best approach while developing applications with wide API level target.
Reflection class is the most solid way, if you have no idea what the class content is and the method exist. But in Android, you know what is supported and what is not supported.
As a result, i didn't like the blog you gave :p
Not necessarily a better answer, but the check you are doing there assumes that the builder of the OS/ROM set that value correctly. If it was not set correctly, then you may try to access a method in SDK 9 that really isn't there. Using reflection is the only way to be 100% sure you do not generate a runtime error by trying to call a non-existent method.

how can we implement CAN Application Layer(CAL) protocol in iphone/android

I need to interface a device which is supporting CANBus ,So for communication with that I need to follow CAL,So can any one help that ho can I implement
CAN Application Layer(CAL) protocol in iphone/android .
Please help i am not getting any way to solve it
"I need to interface a device which is supporting CANBus ,So for
communication with that I need to follow CAL"
The second part of that statement doesn't follow necessarily from the first. There are plenty of devices and systems that communicate via a CAN bus that don't use a formal higher level application framework.
First, you need to be able to communicate with the can bus from your application. Your mentioning iphones suggests you'll be targeting consumer handsets, none of which will have a CAN interface. So you need to incorporate some adapter hardware (there are usb adapters, and android at least has usb hardware access baked into the SDK).
If you do then also need to communicate with components that implement a higher level application framework like CANopen on top of the CAN layer, your options are:
Get your hands on the specification from whatever group maintains
it, and implement it in your language and framework of choice. This is likely a substantial effort.
Purchase or find an open source implementation. If you purchase the source code for a C implementation, you can compile it into a shared library for your target architecture, and, using android as an example, write a native wrapper for that shared library using the Android NDK to expose it to your java code. If you could purchase the source code for a java implementation, you might be able to port it so that it works natively on android.
Then you need to glue the data layer together with the application layer, and this will likely be custom development no matter what.
You need the hardware to support it. I've found Gwentech's GT1026 to work well for can bus to android, but it only works on Android using USB.

Android Equalizer for API Level < 9

I'm looking for a way to use an equalizer within my app which does not rely on the
android.media.audiofx package especially android.media.audiofx. Equalizer class because these are only available for api level > 9.
Does anybody know about native libraries which work well under android? I've found mpg123 but it seems that this library is very slow. Or is there even another way to implement an equalizer without native librarys?
I did quite a bit of research on this and found that you would have to likely rewrite the entire AudioTrack library in order to accomplish this.
It would require heavy DSP which would be best accomplished using the NDK, if you really want to do it.
Otherwise, I would just write a wrapper that tells the application which API level you're in, and disable those features.
Here is the abstract I wrote on this problem:
http://isthisonthetest.com/?q=node/12
Hope this helps!
EDIT:
This link has been getting a few hits (and the link was broken), so I redirected it to a blog post I just made with the original text. The URL above should work now.

Categories

Resources