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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:42:26+00:00 2026-05-29T08:42:26+00:00

Edit: I just moved my HTTPRequest code into the onCreate, and now all of

  • 0

Edit: I just moved my HTTPRequest code into the onCreate, and now all of a sudden it works! Can someone tell me why it does not work when called from the button click? **

I’m using HTTP request to read in some info, but it keeps crashing.

The exact same HttpRequest method works in another class in my app.

It seems to be when I try to assign the String response to something, in this case a TextBox, it times out?

This is the code that contains the HttpRequest:

public class InfoScreen extends Activity
{
    @Override
    protected void onCreate(Bundle icicle)
    {
       super.onCreate(icicle);
       setContentView(R.layout.Infoscreen);
    }

    public void InfoClicked(View target) throws Exception {
        TextView t1 = (TextView)findViewById(R.id.tp1);
        String p1 = "";
        p1 = t1.getText().toString();

        TextView t2 = (TextView)findViewById(R.id.tp2);
        String p2 = "";
        p2 = t2.getText().toString();
        String serverresponse="";
         BufferedReader in = null;

            try {
                HttpClient client = new DefaultHttpClient();
                HttpGet request = new HttpGet();
                String geturl = "http://www.MySite.com/send.aspx?code=rfpaefsJIOLMNSBFep";
                geturl = geturl + "&param1=" + p1;
                geturl = geturl + "&param2=" + p2;
                request.setURI(new URI(geturl));

                Log.e("MyApp :: ", "URI: " + request.getURI());
                Log.e("MyApp :: ", "URI Params: " + request.getParams());
                Log.e("MyApp :: ", "URI Request Line: " + request.getRequestLine());

                HttpResponse response = client.execute(request);
                in = new BufferedReader
                (new InputStreamReader(response.getEntity().getContent()));
                serverresponse =  in.readLine();
                in.close();

                } 

            catch (Exception e) {
                Log.e("MyApp :: ", "Error getting Info using HTTP");
                e.printStackTrace();
            }


        TextView t3 = (TextView)findViewById(R.id.tInfoStatus);

        t3.setText(serverresponse);

    }

Here is part of my log file which I believe contain relevant messages:

02-07 19:05:09.636 E/MyApp :: (23414): URI: http://www.mysite.com/send.aspx?code=rfpaefsJIOLMNSBFep&param1=Gggg&param2=Bnn
02-07 19:05:09.636 E/MyApp :: (23414): URI Params: org.apache.http.params.BasicHttpParams@4010bac8
02-07 19:05:09.644 E/MyApp :: (23414): URI Request Line: GET http://www.MySite.com/send.aspx?code=sdfgkiukjehgefsJIOLMNSBFep&param1=Gggg&param2=Bnn HTTP/1.1
02-07 19:05:13.023 I/ActivityManager(  107): Start proc com.keramidas.TitaniumBackup for broadcast com.keramidas.TitaniumBackup/.PackageEventsReceiver: pid=23520 uid=10112 gids={1015, 3003}
02-07 19:05:13.027 D/AndroidRuntime(23414): Shutting down VM
02-07 19:05:13.027 W/dalvikvm(23414): threadid=1: thread exiting with uncaught exception (group=0x40015578)
02-07 19:05:13.042 E/AndroidRuntime(23414): FATAL EXCEPTION: main
02-07 19:05:13.042 E/AndroidRuntime(23414): java.lang.IllegalStateException: Could not execute method of the activity
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.view.View$1.onClick(View.java:2154)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.view.View.performClick(View.java:2538)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.view.View$PerformClick.run(View.java:9152)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.os.Handler.handleCallback(Handler.java:587)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.os.Looper.loop(Looper.java:130)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.app.ActivityThread.main(ActivityThread.java:3688)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at java.lang.reflect.Method.invokeNative(Native Method)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at java.lang.reflect.Method.invoke(Method.java:507)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at dalvik.system.NativeStart.main(Native Method)
02-07 19:05:13.042 E/AndroidRuntime(23414): Caused by: java.lang.reflect.InvocationTargetException
02-07 19:05:13.042 E/AndroidRuntime(23414):     at java.lang.reflect.Method.invokeNative(Native Method)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at java.lang.reflect.Method.invoke(Method.java:507)
02-07 19:05:13.042 E/AndroidRuntime(23414):     at android.view.View$1.onClick(View.java:2149)
02-07 19:05:13.042 E/AndroidRuntime(23414):     ... 11 more
02-07 19:05:13.042 E/AndroidRuntime(23414): Caused by: java.lang.NullPointerException
02-07 19:05:13.042 E/AndroidRuntime(23414):     at com.MyApp.lmanywhere.InfoScreen.InfoClicked(InfoScreen.java:77)
02-07 19:05:13.042 E/AndroidRuntime(23414):     ... 14 more
02-07 19:05:13.054 W/ActivityManager(  107):   Force finishing activity com.MyApp.lmanywhere/.InfoScreen
02-07 19:05:13.058 D/InputDispatcher(  107): findTouchedWindow finished: injectionResult=-1, injectionPermission=1, timeSpentWaitingForApplication=1587.8ms
02-07 19:05:13.058 D/InputDispatcher(  107): findTouchedWindow finished: injectionResult=-1, injectionPermission=1, timeSpentWaitingForApplication=1589.5ms
02-07 19:05:13.074 E/        (  107): Dumpstate > /data/log/dumpstate_app_error
02-07 19:05:13.148 I/dumpstate(23526): begin
02-07 19:05:13.496 I/StatusBarPolicy(  184): onDataActivity-D:3
02-07 19:05:13.562 W/ActivityManager(  107): Activity pause timeout for HistoryRecord{4094b440 com.MyApp.lmanywhere/.InfoScreen}
  • 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-29T08:42:27+00:00Added an answer on May 29, 2026 at 8:42 am

    I believe this problem might be the result of bad design on my part. I placed the HTTPRequest inside a button click, which caused a noticeable delay during the click. Horrible UI design, but I thought it was ok for a “first draft” and for testing.

    I suspect my phone was crashing due to this delay, that the OS expected a faster response to a button click. I’m using a custom ROM and maybe this wouldn’t happen on other phones. There would also be little clue in the Log or in my Code, since technically the code was fine.

    At any rate, after putting the HTTPRequest inside its own thread using AsyncTask it works great.

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

Sidebar

Related Questions

EDIT I've just started skimming Codd's famous 1970 paper that started it all, that
I just can't remember the terminology used for this and other related properties. EDIT
I have just successfully installed CakePHP and I see that I can edit the
EDIT: Just to make things clear, this problem was caused by a typo in
I wanted to edit just the first line of a 4 MB file. When
(Edit: randrange is just random.randrange, I didn't write my own RNG) I'm trying to
Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls
** EDIT ** Nevermind, just needed to take out the parens... I get this
EDIT AGAIN ... I'm just a dummy and figured it out! EDIT: So, it
edit alright, I guess C is painful in nature--Just, this part, is particularly painful.

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.