Closed GoogleCodeExporter closed 9 years ago
This seems to only happen when using NetHttpTransport [1]. Since you are on
Android 4.3, you are recommended to use the ApacheHttpTransport, which you
should get by default if you call AndroidHttp.newCompatibleTransport() [2].
NetHttpTransport depends on the old javanet library and is less preferable when
other alternatives exist.
[1] http://stackoverflow.com/a/21618255/3882262
[2]
https://code.google.com/p/google-http-java-client/source/browse/google-http-clie
nt-android/src/main/java/com/google/api/client/extensions/android/http/AndroidHt
tp.java
Original comment by wonder...@google.com
on 29 Dec 2014 at 10:19
Appreciate the update.
If I read correctly, AndroidHttp.newCompatibleTransport() returns
NetHttpTransport, not ApacheHttpTransport if the Android API version exceeds 9
(i.e 18 for Android 4.3).
public static HttpTransport newCompatibleTransport() {
return AndroidUtils.isMinimumSdkLevel(9) ? new NetHttpTransport() : new ApacheHttpTransport();
}
[2] states:
There is no guarantee that Apache HTTP transport will continue to work in
future SDKs. Therefore, this method uses {@link NetHttpTransport} for
Gingerbread or higher, and otherwise {@link ApacheHttpTransport}.
To be crystal clear on Google's recommendation: Avoid NetHttpTransport in all
cases? Only where Android API < 9? Only where Android API < 18?
Original comment by davidpbr...@gmail.com
on 13 Jan 2015 at 8:46
Sorry I was mistaken. On platforms other than Android, ApacheHttpTransport is
preferred over NetHttpTransport. But Android doesn't seem to get along with
ApacheHttpTransport so you'd have to use NetHttpTransport. Plus, Android's
HttpUrlConnection's implementation is better than JDK's so it's not too bad.
Using NetHttpTransport, you can manipulate request properties by overriding
ConnectionFactory#openConnection(URL), in which you open a connection and set
the property before returning.
https://github.com/google/google-http-java-client/blob/master/google-http-client
/src/main/java/com/google/api/client/http/javanet/ConnectionFactory.java
Original comment by wonder...@google.com
on 1 Mar 2015 at 11:50
Original issue reported on code.google.com by
davidpbr...@gmail.com
on 9 Apr 2014 at 8:02