0

I am not getting any response, what is the problem in my code. Due to privacy policies I am not providing correct URl.

public static String URL = "http://www.example.com/web_service/mainAPI.php";
final String body = String.format("rquest={\"method\":\"upcoming_shows\",\"body\":[{}]}");
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.upcoming_show);
    try{    
        Log.d("In Try", "Going...");
        final HttpClient client = new DefaultHttpClient();
        final HttpPost postMethod = new HttpPost(URL);
        postMethod.setEntity(new StringEntity(body, "utf-8"));
        final HttpResponse response = client.execute(postMethod);
        final String responseData = EntityUtils.toString(response.getEntity(), "utf-8");
        Toast.makeText(UpcomingShow.this, responseData, Toast.LENGTH_SHORT).show();
        }catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }

please give me some solution.

Pradeep Pati
  • 5,779
  • 3
  • 29
  • 43
RBL
  • 63
  • 2
  • 9

1 Answers1

2
  1. You are trying to access network on UI thread, thats no longer allowed. See here. and here.
  2. You probably have a typo in your String body, it says rquest, I believe it should be request (on line 2)
Community
  • 1
  • 1
Pradeep Pati
  • 5,779
  • 3
  • 29
  • 43