What android API's work with the HttpPost
function and what android API's work with the HttpURLConnection
function? I'm trying to create Java code for an android app that calls a PHP file to connect with a database, and I want to make sure that my code is compatible with whatever Android API the mobile phone is running on.
Apache HTTP, and therefore HttpPost
, is deprecated, HTTPURLConnection
is encouraged, but it really doesn't matter.
You could even use Retrofit, Ion, AsyncHttpClient, Volley, OkHttp ... And the Android HTTP library list goes on.
If you are truly concerned about API version, use HttpURLConnection
If you want to use legacy Apache HTTP, then compile it
android {
compileSdkVersion ...
buildToolsVersion "..."
useLibrary 'org.apache.http.legacy' // Add this line