Skip to content

Commit 6aab246

Browse files
committed
Update README docs
1 parent f531e52 commit 6aab246

File tree

1 file changed

+25
-42
lines changed

1 file changed

+25
-42
lines changed

README.md

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ approach that keeps the details of the OAuth process abstracted from the end-use
66
This library leverages a few key libraries underneath to power the functionality:
77

88
* [scribe-java](https://github.com/scribejava/scribejava) - Simple OAuth library for handling the authentication flow.
9-
* [Android Async HTTP](https://github.com/loopj/android-async-http) - Simple asynchronous HTTP requests with JSON parsing.
9+
* [Android Async HTTP](https://github.com/codepath/asynchttpclient) - Simple asynchronous HTTP requests with JSON parsing.
1010

1111
## Installation
1212

@@ -24,7 +24,7 @@ Next, add this line to your `app/build.gradle` file:
2424

2525
```gradle
2626
dependencies {
27-
compile 'com.codepath.libraries:android-oauth-handler:1.3.1'
27+
compile 'com.codepath.libraries:android-oauth-handler:2.1.1'
2828
}
2929
```
3030

@@ -51,12 +51,12 @@ public class TwitterClient extends OAuthBaseClient {
5151

5252
public TwitterClient(Context context) {
5353
super(context, REST_API_INSTANCE, REST_URL,
54-
REST_CONSUMER_KEY, REST_CONSUMER_SECRET, REST_CALLBACK_URL);
54+
REST_CONSUMER_KEY, REST_CONSUMER_SECRET, null, REST_CALLBACK_URL);
5555
}
5656

5757
// ENDPOINTS BELOW
5858

59-
public void getHomeTimeline(int page, AsyncHttpResponseHandler handler) {
59+
public void getHomeTimeline(int page, JsonHttpResponseHandler handler) {
6060
String apiUrl = getApiUrl("statuses/home_timeline.json");
6161
RequestParams params = new RequestParams();
6262
params.put("page", String.valueOf(page));
@@ -169,9 +169,9 @@ with a `JsonHttpResponseHandler` handler:
169169
// SomeActivity.java
170170
RestClient client = RestClientApp.getRestClient();
171171
client.getHomeTimeline(1, new JsonHttpResponseHandler() {
172-
public void onSuccess(int statusCode, Header[] headers, JSONArray json) {
172+
public void onSuccess(int statusCode, Headers headers, JSON json) {
173173
// Response is automatically parsed into a JSONArray
174-
// json.getJSONObject(0).getLong("id");
174+
// json.jsonArray.getJSONObject(0).getLong("id");
175175
}
176176
});
177177
```
@@ -180,27 +180,18 @@ Based on the JSON response (array or object), you need to declare the expected t
180180

181181
```java
182182
RestClient client = RestClientApp.getRestClient();
183-
client.get("http://www.google.com", new AsyncHttpResponseHandler() {
183+
client.get("http://www.google.com", new JsonHttpResponseHandler() {
184184
@Override
185-
public void onSuccess(int statusCode, Header[] headers, String response) {
185+
public void onSuccess(int statusCode, Headers headers, String response) {
186186
System.out.println(response);
187187
}
188188
});
189189
```
190190

191-
Check out [Android Async HTTP Docs](http://loopj.com/android-async-http/) for more request creation details.
191+
Check out [Android Async HTTP Docs](https://github.com/codepath/asynchttpclient) for more request creation details.
192192

193193
## Extra Functionality
194194

195-
### Adding Request Headers
196-
197-
In certain cases, requests will require a particular custom header to be passed through the client. In this case, you can add custom headers to the client that will be added to all requests with:
198-
199-
```java
200-
RestClient client = RestApplication.getRestClient();
201-
// Specify the header to append to the request
202-
client.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1)");
203-
```
204195

205196
### Access Authorization
206197

@@ -226,40 +217,32 @@ This can be helpful in cases where you must add a flag such as when encountering
226217

227218
You can log out by clearing the access token at any time through the client object:
228219

229-
You can log out by clearing the access token at any time through the client object:
230-
231220
```java
232221
RestClient client = RestApplication.getRestClient();
233222
client.clearAccessToken();
234223
```
235224

236-
### Enabling a Proxy
225+
### Debugging
237226

238-
In order to [troubleshoot API calls](http://guides.codepath.com/android/Troubleshooting-API-calls) using a method such as Charles Proxy, you'll want to enable proxy support with:
227+
In order to [troubleshoot API calls](http://guides.codepath.com/android/Troubleshooting-API-calls), you can take advantage of the Stetho library:
239228

229+
Next, initialize Stetho inside your Application object:
240230
```java
241-
RestClient client = RestApplication.getRestClient();
242-
client.enableProxy();
231+
public class MyApplication extends Application {
232+
public void onCreate() {
233+
super.onCreate();
234+
Stetho.initializeWithDefaults(this);
235+
}
236+
}
243237
```
244238

245-
Proxies are useful for monitoring the network traffic but require a custom SSL certificate to be added to your emulator or device. Because Android API 24 and above now require [explicit control](https://developer.android.com/training/articles/security-config.html) on custom SSL certificates that are used in apps, you will need to allow for added certs to be added by specifying `res/xml/network_security_config.xml` in your app:
246-
239+
Edit the manifest.xml file in your project. To let the Android operating system know that you have a custom Application class, add an attribute called `android:name` to the manifest’s application tag and set the value to the name of your custom Application class.
247240
```xml
248-
<?xml version="1.0" encoding="utf-8"?>
249-
<network-security-config>
250-
<debug-overrides>
251-
<trust-anchors>
252-
<!-- Trust user added CAs while debuggable only -->
253-
<certificates src="user" />
254-
</trust-anchors>
255-
</debug-overrides>
256-
</network-security-config>
241+
<application
242+
...
243+
android:name=".MyApplication"
244+
...
245+
>
257246
```
258247

259-
Inside your AndroidManifest.xml file, make sure to include this `networkSecurityConfig` parameter:
260-
261-
```xml
262-
<application
263-
android:name=".RestApplication"
264-
android:networkSecurityConfig="@xml/network_security_config"
265-
```
248+
You can then use `chrome://inspect`, pick the app currently running, and click on the Network tab to view. See [this guide](https://github.com/codepath/android_guides/wiki/Debugging-with-Stetho) for more context.

0 commit comments

Comments
 (0)