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 6983759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:27:40+00:00 2026-05-27T18:27:40+00:00

trying to do a simple communication test between my PC and phone (currently testing

  • 0

trying to do a simple communication test between my PC and phone (currently testing with emulator)
I have created a c# Rest service that works ok

URL: http://192.168.1.100:8000/REST/client
Result:

TEST STRING!

I have a Call function in my android app that looks like this:

public void call() 
{ 
    String URL = "http://192.168.1.100:8000/REST/client";
    EditText txt = (EditText) findViewById(R.id.Textbox);
    String Result = "";
    Toast.makeText(Helloworld.this, "STARTING", Toast.LENGTH_SHORT);
    HttpClient hc = new DefaultHttpClient();
    HttpGet request = new HttpGet(URL);
    ResponseHandler<String> handler = new BasicResponseHandler();
    try{
        Result = hc.execute(request,handler);
    }
    catch (ClientProtocolException e) {   
        e.printStackTrace();   
    } catch (IOException e) {   
        e.printStackTrace();   
    } 
    txt.setText(Result);
    Toast.makeText(Helloworld.this, Result, Toast.LENGTH_SHORT);
    hc.getConnectionManager().shutdown();

} 

i call this from a button,

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button button = (Button) findViewById(R.id.button1);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            EditText txt = (EditText) findViewById(R.id.Textbox);
            txt.setText("calling!", TextView.BufferType.EDITABLE );
            call();
        }
        });

few problems, with this code as is, if i run it i dont see any Toast msgs and the textbox isnt updated. if however i remove the call() from the onclick, the textbox is updated. it seems as though the call is hanging, but even if it was, wouldnt i see the text updated anyways?

  • 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-27T18:27:41+00:00Added an answer on May 27, 2026 at 6:27 pm

    Assuming that it can reach your service etc, you should be doing it with AsyncTasks and calling invalidate to make sure the updates are shown on the screen. Also, you have to call .show() on makeText(). I haven’t tested this but it should be the right idea.

    public void doBeginCall()
    {
      Toast.makeText(this, "Call started", Toast.LENGTH_SHORT).show();
      new CallTask().execute(null);  
    }
    
    public void onCallComplete(String result)
    {
        Toast.makeText(this, "Call complete", Toast.LENGTH_SHORT).show();
        ((EditText)findViewById(R.id.Textbox)).setText(result);
        invalidate();
    }
    
    class CallTask extends AsyncTask<String, String, String> 
    {
    
        protected void onPostExecute(String result) 
        {
            onCallComplete(result);
        }
    
        @Override
        protected TaskResult doInBackground(String... params) 
        {           
            return call();
        }
    }
    
    public String call() 
    { 
        String URL = "http://192.168.1.100:8000/REST/client";
        String Result = "";
        HttpClient hc = new DefaultHttpClient();
        HttpGet request = new HttpGet(URL);
        HttpResponse hr = null;
        BasicResponseHandler handler = new BasicResponseHandler();
        try
        {
            hr = hc.execute(request);
        }
        catch (ClientProtocolException e) 
        {   
            e.printStackTrace();   
        } 
        catch (IOException e) 
        {   
            e.printStackTrace();   
        } 
        hc.getConnectionManager().shutdown();
        return handler.handleResponse(hr);
    }
    

    Also, you need to have the proper permissions set up for your app. Include the following line in your manifest xml:

    <uses-permission android:name="android.permission.INTERNET"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple client-server ASP.NET app; communication is via WCF service. All
I'm trying to create a client for a WCF service that I have hosted
I'm trying to write a simple/small Windows Communication Foundation service application in Visual Basic
I'm trying to use Simple Savant within my application, to use SimpleDB I currently
I'm trying to put together a very simple REST-style interface for communicating with our
I am currently trying to find a simple, easy way to publish/broadcast stock tick
I'm trying to implement basic communication through sockets, what I have now is: server
No, I'm not trying to make an annoying popup. I have a simple webpage
I am trying to get some simple UDP communication working on my local network.
I am trying to write a simple console app that POSTs to a page

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.