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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:24:06+00:00 2026-06-07T10:24:06+00:00

Possible Duplicate: Calling Method in Android I’m trying to contatct an API. I have

  • 0

Possible Duplicate:
Calling Method in Android

I’m trying to contatct an API. I have yet to see if its even working…but my test message is not even working.

Here’s my MainActivity:

public class MainActivity extends Activity {

public final static String EXTRA_MESSAGE = "com.example.test.MESSAGE";


@SuppressLint("ParserError")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}



public void sendIP(View view){
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    startActivity(intent);


}

Here’s the DisplayMessageActivity:
-“hello” should be written on the screen, but instead its blank. I figure if that’s not showing up, then my request probably didn’t make it anywhere either, so advice on that would be helpful as well.

public class DisplayMessageActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);




        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://api.site/");

        try {
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);


            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);

            String test = "hello";

            TextView textView = new TextView(this);
            textView.setTextSize(40);
            textView.setText(test);
            //TextView myTextView = (TextView) findViewById(R.id.myTextView);
           // myTextView.setText(test);

        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }


}
}

And I have allowed access to internet in the manifest!

Thanks!

  • 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-07T10:24:07+00:00Added an answer on June 7, 2026 at 10:24 am

    You need a setContentView() to an xml layout or directly to your textview in the onCreate() of your DisplayMessageActivity.

    You also need to move the network operation to an AsyncTask or otherwise get it off the UI thread. While some of the old official samples are bad about this, it’s never been a good idea, and on more recent Android versions will result in a proactive crash.

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

Sidebar

Related Questions

Possible Duplicate: Retrieving the calling method name from within a method (C#) I have
Possible Duplicate: Calling virtual method in base class constructor Calling virtual functions inside constructors
Possible Duplicate: Calling Python from JavaScript I have a test.py and test.js . I
Possible Duplicate: Calling a method named “string” at runtime in Java and C I
Possible Duplicate: Reflection in C#: How do I get the calling method name and
Possible Duplicate: Calling a webservice that uses ISO-8859-1 encoding from WCF I am trying
Possible Duplicate: Confusing Template error I have a templated class with a templated method.
Possible Duplicate: Calling generic method with a type argument known only at execution time
Possible Duplicate: Why does asynchronous delegate method require calling EndInvoke? Is Delegate.EndInvoke() really necessary?
Possible Duplicate: Calling class method through NULL class pointer #include <iostream> using namespace std;

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.