Peter Peter - 3 months ago 8
Android Question

Do new libraries work with older android devices?

I am trying to build an android app, exchanging data with a PHP server via JSON. Thus I need to learn working with GSON,

org.apache.http.*
libraries - so called


apache library module


.

I've studied several examples that use lib classes like
HttpClient
,
HttpEntity
,
HttpResponse
and the like.
When I try to add similar code into my app, I get a warning that virtually all library classes with Http* prefix are deprecated.

I have learned that Android team has deprecated apache module since API 22+

There are sevaral threads suggesting to use
URLConnection
instead.
Like this one.

My question is: Will my app work on older android devices (android 2.0.x - 4.4), if I'd follow the advice to use URLConnection ? I build on AndroidStudio 2.1.2 / Gradle.

If there is even better option than URLConnection, your hint will be appreciated. No proprietary libraries, please. I prefer standard stuff.

Answer

Will my app work on older android devices (android 2.0.x - 4.4), if I'd follow the advice to use URLConnection ?

HttpURLConnection is not recommended prior to Android 2.2 due to bugs. Since few devices run such Android versions, this should not be a major impediment. Otherwise, HttpURLConnection works fine, though its API leaves something to be desired. Personally, I recommend OkHttp3.

Comments