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/
Related
i have used zkSforce library for IOS but now i want use for android because c panel created in saleforce so i don't have library and any solution for this. Please provide me any hint or solution.
Thanks for advance
You have 2 main options
1) Mobile SDK for Android, see https://github.com/forcedotcom/SalesforceMobileSDK-Android this provides a wrapper for the Salesforce REST API and includes pre-canned implementations of the OAuth login flows etc.
2) WSC see https://github.com/forcedotcom/wsc is primarily a java soap stack and wraps the Salesforce SOAP APIs (this is the same API that ZKSforce wraps). This should be usable on Android, but provides nothing Android specific.
I'd recommend (1) unless you have specific requirements to call the SOAP API.
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?
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.
How can I get that API into our Android project.
As per my understanding the you have a code written on J2ME platform where you are using javax.microedition.io
But as you are making an application in Android and Android does not have the package available, so you need to use any library to achieve your goal.
Here is a open source library for parsing Ksoap2 data
http://code.google.com/p/ksoap2-android/
Again you can use the following tutorial to get started
http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data
Currently I am working on an iPhone app. But the company also would like to have an android version for this app.
I have programmed all the request by Soap and used for the iPhone the Soap Request Generator of Sudz-C.
I am wondering now if something similar exists for the Android, It would be nice if I don't have to program this all by myself.
Anyone have some experiences or ideas?
You can use
http://easywsdl.com
website to generate all required java classes for your webservice. It uses ksoap2 library and supports many features like objects sent as references (WCF IsReference), complex inheritance, document and rpc style of webservice, all standard data types (including normal enums and IsFlag enums), and much more
ksoap2-android is what you are looking for, it will send/recive soap request's, is easy to use and on MIT license
I go through a lot of solution solution in WSDL 2 android. google don't matter about SOAP service and provide anything for it. wsdl2java won't work in most of case, some library cannot be use by android SDK. I suggest you to use http://easywsdl.com.
you'll see you can edit your own package name, class prefix and many other parameters depends on your need. If you have complex data and your are familiar to use Gson (https://code.google.com/p/google-gson/) to send parameter between your activities don't check "Use JodaDate" that is a great library for using date, but Gson doesn't support it (yet).
If you have few services that don't work (yes that can happen, depend of your WSDL configuration file), report it to contact and they will make the possible to fix your issue like they did for me.
The generator is fast. you will receive all your generated code and the .jar that you'll have to import into your project.