Frist PHP Learning with Android make a Application

 PHP Included Your Application Using Volley Library.


Step 1

  • Users Internet Permission manifest 
  • Impediment Volley Library in your Android studio
  • Go to Your Java code
  • Call StringRequest Method 
  • Into the first bracket (Request.Method.GET, Url, 
                              new response Method

                        and new Responses Error Method Called

Step 2

  • Create a PHP file on your website 
  • Copy the file link 
  • And pest URL in the Java code

Semple:-

StringRequest stringRequest = new StringRequest(Request.Method.GET, "https://thispractice.000webhostapp.com/apps/hello.php",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {

}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {

}
}
);



Use newRequestQueue



StringRequest stringRequest = new StringRequest(Request.Method.GET, "https://thispractice.000webhostapp.com/apps/hello.php",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
tvDisplay.setText(response);
progressBar.setVisibility(View.GONE);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
tvDisplay.setText("Didn't work it");
progressBar.setVisibility(View.GONE);
}
}
);
RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this);
requestQueue.add(stringRequest);




Post a Comment

Post a Comment (0)

Previous Post Next Post