Android Client-Server through NDK - android

I want to communicate with Apache Tomcat server using android ndk(native code).
Is it possible to communiate , Is there any other alternative to do so ?
Thanks.

Standard POSIX socket code can be used for networking in Android. The socket system call api for android can be found at https://github.com/android/platform_bionic/blob/master/libc/SYSCALLS.TXT (this is a clone of the official android C library repo). This should take care of your network layer requirements. As for the code, the code for a simple network client can be found at http://en.wikipedia.org/wiki/Berkeley_sockets#Client. However, this is only in the case you want to write up your own application layer protocol( I assume HTTP) code. It is better to use an HTTP client library instead,.
As for an HTTP client library, you could use libcurl or any similar library for communication. A good list of available libraries on the libcurl site at http://curl.haxx.se/libcurl/competitors.html.
Note: You will most probably not get any compiled library. You'll need to compile and add the library into your application before you compile your code, and the library will need to be a part of the install package as well.

Related

Is Volley only available for Android?

I'm trying to write a Java code that makes HTTP requests that would run on both Windows and Android.
I'm given to understand that for Windows, Apache's HTTPComponents is used, and for Android Volley is used. But it appears neither work on the other platform.
Is there a library that works on both? Or a uniform API layer on one of them that based on the OS decides what to use?
I'm using VS Code for Windows and Android Studio for Android, both latest versions, if it is relevant.
Thanks in advance!
you can use the Ktor client
but it requires Kotlin language
You can use Retrofit. According to the official website, Retrofit is a type-safe HTTP client for Java and Android which was developed by Square. With Retrofit, all you need to do is declare a Java interface to represent your API. Then, you can pass the API configuration to Retrofit, and you will get back a Java class implementation of your interface.
You can give a shot to Swagger Editor. It generates client code for languages, not for platforms. You need to prepare a yaml file then click "generate client" -> "java". After then, you need to implement downloaded client into your project as gradle project.
code generator: https://editor.swagger.io/
documentation: https://swagger.io/docs/open-source-tools/swagger-editor/

Interface Android Keystore from NDK

Introduction
I am currently working on a solution that would use Android Keystore new features (since Marshmallow , API level 23).
My app use both Java and C++ (NDK) and I have some critical operation that needs to be perform from native code.
I am able to use properly the new Keystore from Java.
Unfortunately, the Android C++ sources are not documented and I have tried to look into it.
Question
I would like to perform operation from both Java and C++.
The only dynamic library that I could use and interface is the IKeystoreService and with its associated library /system/lib/libkeystore_binder.so.
I have been able to include headers and the library and compile it.
But since the only connection point I can use is a Binder between Java and C++ IKeystoreService(s), I can't find which data I am supposed to use in order to achieve a simple AES encryption (for example).
Would anyone have any insight ?
Thanks

Can the Eventful java client library be used for Android?

I am creating an app showing local events for android. I was hoping to use the Eventful API, since that came with its own java-based client library. However, I'm not sure if it's fit for Android, since I know a lot of these java based client libraries use stuff Android doesn't support.
So, does anybody know if it works?
My entire project is available # github if you want to check it out for yourself.
The API is found here.
Android does not have have issues with Java client libraries. It is build on top of standard Java, and can use all of the framework features.
Furthermore, it looks like this API offers a RESTful interface, which is for sure supported by Android.
Bottom line, I do think you can use this API in Android without issue.
I'd say the easiest way is to compile and run an application that embeds the library and tests a few methods.
Typically, you may have issues with the way the networking is handled. There are 2 main ways in android to do HTTP, the Java and the Apache way, I think the Java URL API is fully supported and very close to the actual Java version, but the Apache has some hidden differences.
The main risks you'll have are A/ that it uses classes or packages that are not present on Android. B/ that a class does not behave as expected, which does happen from time to time, as the Android implementation is entirely specific.
Apparently you have already tried to run an android app with the library included? Did you encounter a specific error? If you, can you post the stacktrace?

XMPP / Jingle Voice Library for Android

I'm looking for a Jingle library (or app code) that exists on android and supports Voice for Gtalk or any xmpp in general.
I don't really want to write JNI for libjingle. I would prefer something in java /android.
Check this repo it should help.
webrtc-jingle-client
There is no java port for it. Its better to use the libjingle c .so and use JNI on android.

What is the difference between Smack and aSmack?

I am not able to use Smack on Android whereas aSmack works perfectly? When compared the source code it looks somewhat similar, where does the difference comes from?
What is the difference between Smack and aSmack?
Smack < 4.1 does not work on Android, mostly because of APIs missing on Android (e.g. most of the javax APIs). That is the reason the aSmack build environment was born. It is a way to modify Smack so that it can be used on Android.
Besides many minor changes the biggest changes are
Disabling XMPP SASL auth methods that are not supported on Android
Using apache harmony for SASL instead of the javax API
Make sure to read the README and and init the relevant code before doing any XMPP related actions.
More information can be found # https://github.com/Flowdalic/asmack/wiki/Modifications
As the project description states, ASmack adds a set of patches to regular Smack. Check this conversation for further details.
Regards.
You can see how things are done in talkmyphone. I think they are using smack with android.
It modifies Smack to allow it to work on Android.
I am not sure of what those changes are, with the exception of altering the ProviderManager mechanism so that it can load the smack.providers XML file from an Android friendly directory. By default Smack loads this from its own resource directory, which is not reachable in Android.

Categories

Resources