Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7602675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:28:20+00:00 2026-05-30T23:28:20+00:00

I have this code for an Android application I’m trying to create into interact

  • 0

I have this code for an Android application I’m trying to create into interact with my PHP website. I have the android.permission.INTERNET permission activated and it keeps creating a toast that says “ERROR.” instead of the contents of the website. Here is my only java file:

package com.http.request;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class HttprequestActivity extends Activity {
    /** Called when the activity is first created. */

    private String doHTTPRequest(String url){
        String results = "ERROR";
        try
        {
            HttpClient hc = new DefaultHttpClient();
            HttpPost post = new HttpPost(url);

            HttpResponse rp = hc.execute(post);

            if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
            {
                results = EntityUtils.toString(rp.getEntity());
            }
        }catch(IOException e){
            e.printStackTrace();
        }
        return results;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        String results = doHTTPRequest("http://www.yahoo.com");
        Toast.makeText(getApplicationContext(), results, Toast.LENGTH_LONG).show();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:28:22+00:00Added an answer on May 30, 2026 at 11:28 pm

    I would check to make sure that,

    1. If there is an exception being thrown, investigate what is causing the IOException
    2. Your server could potentially be returning a non-200 response code.

    Put in some breakpoints and see whats happening there. My bet is on the response code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing Android application where I use this code: Date d=new Date(new
I have javascript code that i am trying to mimic in an android application:
Hey guys, I have this code for an android application, the funny thing is
I have this code on my Android phone. URI uri = new URI(url); HttpPost
I have this code that performs an ajax call and loads the results into
I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
I have an android application in which I need to get the HTML code
I am trying to port some c++ code to my android application using NDK.
I am trying to make my Android application run some code when run from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.