I'm experienced with PHP, JavaScript and a lot of other scripting languages, but I don't have a lot of experience with Java or Android.
I'm looking for a way to send POST data to a PHP script and display the result.
I'm experienced with PHP, JavaScript and a lot of other scripting languages, but I don't have a lot of experience with Java or Android.
I'm looking for a way to send POST data to a PHP script and display the result.
This is an example of how to POST multi-part data WITHOUT using external Apache libraries:
Use the open source
okHttp
library from Square.okHttp
works from Android 2.3 and up and has an Apache 2.0 license on GitHub.Sending POST data is as simple as adding the following in an AsyncTask:
okHttp
also has a namespace on maven, so adding it to your Android Studio project is simple. Just addcompile 'com.squareup.okhttp3:okhttp:3.11.0'
to your app's build.gradle.Complete Code
Add the following to your activity:
And call it using:
You can use this to send an HTTP POST request to a URL. You can easily send request and get response. I always use this . I fine work to me.
You Also need to Add bellow Jar file in libs folde
Finally edit your build.gradle
In the last Rebuild your project.