Created
May 22, 2021 12:31
-
-
Save ibrahim4851/6b12d65efbdffb2b6dc67f5510f08238 to your computer and use it in GitHub Desktop.
PostObject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun postString(context: Context?) { | |
val queue = Volley.newRequestQueue(context) | |
val sr: StringRequest = object : StringRequest( | |
Method.POST, "http://favor4u.xyz/calisma/samplepost.php", | |
Response.Listener { response -> | |
val res = JSONObject(response) | |
val value = res.getString("value") | |
Toast.makeText(context, "Successful", Toast.LENGTH_SHORT).show() | |
Log.i("value", value) | |
}, Response.ErrorListener { error -> | |
Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show() | |
}) { | |
override fun getParams(): Map<String, String> { | |
val params: MutableMap<String, String> = HashMap() | |
params["value"] = "value" | |
return params | |
} | |
@Throws(AuthFailureError::class) | |
override fun getHeaders(): Map<String, String> { | |
val params: MutableMap<String, String> = HashMap() | |
params["Content-Type"] = "application/x-www-form-urlencoded" | |
return params | |
} | |
} | |
queue.add(sr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment