You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Android SDK utilizes the Java SDK while making some Android-specific additions. This repository can be found [here](https://github.com/watson-developer-cloud/android-sdk). It depends on [OkHttp][] and [gson][].
258
-
259
-
## Configuring the HTTP client
234
+
### Configuring the HTTP client
260
235
261
236
The HTTP client can be configured by using the `configureClient()` method on your service object, passing in an `HttpConfigOptions` object. Currently, the following options are supported:
262
237
- Disabling SSL verification (only do this if you really mean to!) ⚠️
@@ -276,7 +251,71 @@ HttpConfigOptions options = new HttpConfigOptions.Builder()
276
251
service.configureClient(options);
277
252
```
278
253
279
-
## Sending request headers
254
+
### Making asynchronous API calls
255
+
256
+
The basic, synchronous way to make API calls with this SDK is through the use of the `execute()` method. Using this method looks something like this:
However, if you need to perform these calls in the background, there are two other main methods to do this asynchronously: `enqueue()` and `reactiveRequest()`.
265
+
266
+
#### `enqueue()`
267
+
268
+
This method allows you to set a callback for the service response through the use of the `ServiceCallback` object. Here's an example:
If you're a fan of the [RxJava](https://github.com/ReactiveX/RxJava) library, this method lets you leverage that to allow for "reactive" programming. The method will return a `Single<T>` which you can manipulate how you please. Example:
// All the api calls from now on will send the default headers
316
+
```
317
+
318
+
### Sending request headers
280
319
281
320
Custom headers can be passed with any request. To do so, add the header to the `ServiceCall` object before executing the request. For example, this is what it looks like to send the header `Custom-Header` along with a call to the Watson Assistant service:
The basic `execute()`, `enqueue()`, and `rx()` methods make HTTP requests to your Watson service and return models based on the requested endpoint. If you would like access to some HTTP response information along with the response model, you can use the more detailed versions of those three methods: `executeWithDetails()`, `enqueueWithDetails()`, and `rxWithDetails()`. To capture the responses, use the new `Response<T>` class, with `T` being the expected response model.
It does! You should be able to plug this dependency into your Android app without any issue. In addition, we have an Android SDK meant to be used with this library that adds some Android-specific functionality, which you can find [here](https://github.com/watson-developer-cloud/android-sdk).
349
364
350
-
## 401 unauthorized error
351
-
352
-
Make sure you are using the service credentials and not your IBM Cloud account/password.
353
-
Check the API endpoint, you may need to update the default using `setEndPoint()`.
354
-
355
-
## Debug
365
+
### How does debugging work?
356
366
357
367
HTTP requests can be logged by adding a `logging.properties` file to your classpath.
358
368
@@ -383,63 +393,21 @@ INFO: <-- 200 OK https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/di
383
393
384
394
**Warning:** The logs generated by this logger when using the level `FINE` or `ALL` has the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the contents of request and response bodies. This data should only be logged in a controlled way or in a non-production environment.
385
395
386
-
## Build + test
387
-
388
-
To build and test the project you can use [Gradle][] (version 1.x).
389
-
390
-
Gradle:
391
-
392
-
```sh
393
-
cd java-sdk
394
-
gradle jar # build jar file (build/libs/watson-developer-cloud-6.14.0.jar)
395
-
gradle test# run tests
396
-
gradle check # performs quality checks on source files and generates reports
397
-
gradle testReport # run tests and generate the aggregated test report (build/reports/allTests)
398
-
gradle codeCoverageReport # run tests and generate the code coverage report (build/reports/jacoco)
399
-
```
400
-
401
-
## Working with Eclipse and Intellij IDEA
402
-
403
-
If you want to work on the code in an IDE instead of a text editor you can
404
-
easily create project files with gradle:
405
-
406
-
```sh
407
-
gradle idea # Intellij IDEA
408
-
gradle eclipse # Eclipse
409
-
```
410
-
411
-
## Open source @ IBM
412
-
413
-
Find more open source projects on the [IBM Github Page](http://ibm.github.io/)
414
-
415
-
## License
416
-
417
-
This library is licensed under Apache 2.0. Full license text is
418
-
available in [LICENSE](LICENSE).
419
-
420
-
## Contributing
421
-
422
-
See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
396
+
### How can I contribute?
423
397
424
-
## Code of conduct
398
+
Great question (and please do)! You can find contributing information [here](.github/CONTRIBUTING.md).
425
399
426
-
See [CODE_OF_CONDUCT.md](.github/CODE_OF_CONDUCT.md).
400
+
### Where can I get more help with using Watson APIs?
427
401
428
-
### Other
402
+
If you have a question about/problem with using the Watson APIs in general, feel free to ask a question on [dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson) or trusty [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson).
429
403
430
-
If you are having difficulties using the APIs or you have a question about the IBM
0 commit comments