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

  • SEARCH
  • Home
  • 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 8990965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:37:15+00:00 2026-06-15T22:37:15+00:00

I wanted to test if my Android app can sucessfully get the response from

  • 0

I wanted to test if my Android app can sucessfully get the response from a php page, without JSON. The php just contains echo "hello";, but I failed to Toast it. Closest solution I can find is, where I tried to put some parts of it into my code: How can I view the string sent from httppost?

My code as below (updated):

public void onClick(View v) {
    Thread t = new Thread() {
        @Override
        public void run() {
            Log.i("Threaded", "Inside thread!!!");
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://192.168.1.10/fyp/test.php");

            try {
                HttpResponse response = httpclient.execute(httppost);
                InputStream content = response.getEntity().getContent();
                Log.i("Connect", content.toString());

                BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
                StringBuilder sb = new StringBuilder();
                String line = null;

                while ((line = buffer.readLine()) != null) {
                    sb.append(line + "\n");
                }
                Log.i("Connect", sb.toString());

                handler.post(new Runnable() {
                    public void run() {       
                        showToastMessage("hello");       
                      }
                    });
            } catch (Exception e) {
                Log.e("Connect", "Fail");
                e.printStackTrace();
            }
        }

    };
}

The thread seems not running, where the line Log.i("Threaded", "Inside thread!!!"); is not showing in LogCat, which part am I doing wrongly? Note: handler has been declare in the class.

  • 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-06-15T22:37:16+00:00Added an answer on June 15, 2026 at 10:37 pm

    Make sure you perform the toast on the UI thread or else it will fail.
    Either use a Handler or wrap your network operation in a AsyncTask where you pass the result to the onPostExecute method which is processed by the UI thread.

    http://developer.android.com/reference/android/os/AsyncTask.html

    If this is not your problem, add logging to see that you get a response from the server and check your LogCat for the “hello”

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

Sidebar

Related Questions

hm, i have an strange problem... i just wanted to test an app on
So I wanted to test my app on an actual android device. I've debugged
I wanted to change my minSDKversion from 10 to 7 of my android app.
I wanted to test python27 on appengine so I have migrated my app from
I have been developing an android app, and i wanted to test it out
I wanted to implement the ActionBar (Android 4.0) in a test App to see
I have built part of my app and wanted to test it out. All
I wanted to quick test a small snippet of PHP code. So, After doing
I wanted to test my app on the device, but I dont want now
I wanted to test foldl vs foldr. From what I've seen you should use

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.