CURL Library for Android

2019-09-02 12:56发布

问题:

After much struggling, I managed to setup this Android NDK project on eclipse:

https://github.com/gcesarmza/curl-android-ios

...and now it runs. All it does is connect to www.google.com: This is the curl call I make in the Main Activity:

String url = "https://www.google.com";
byte[] content = downloadUrl(url);

I am new to NDK an this CURL library, how can I execute a more complex CURL request such as this file upload command??? :

curl -F file=@audio.wav http://myserver.com

回答1:

The test project that you reproduced does only this, downloadUrl.

If you want something else, you need to write (in C or C++) your own code that uses libCURL. You can start with a generic tutorial.

You will also need to define some JNI wrapper, e.g.

native bool pushFile(String file)

Alternatively, you can use an existing JNI wrapper.