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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:12:41+00:00 2026-06-14T21:12:41+00:00

I’m trying to build up to eventually connecting an Android application to a database

  • 0

I’m trying to build up to eventually connecting an Android application to a database via a webservice. As an intermediate step, I was trying to see if I could get http://codeoncloud.blogspot.com/2012/07/android-php-web-service-client.html working correctly. However, when I copy/paste that and set up the appropriate layout file with a textview, I get an error when trying to run it. Specifically, my code is shown below (I’m trying to run from an emulator on the same machine hence the 10.0.2.2) Any pointers would be greatly appreciated!

package com.example.componenttest;

import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import android.widget.TextView;
import org.apache.http.HttpResponse;
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;

public class AndroidWebActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("10.0.2.2/InterfaceTest/GrabMe.php");
        try {
            TextView tv = (TextView) findViewById(R.id.tv1);
        //tv.setText("CHANGED TEXT");
            HttpResponse response = httpclient.execute(httppost);
            final String str =  EntityUtils.toString(response.getEntity());
            tv.setText(str);
        }
       catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }
    }
}

My error log is shown below:

11-24 22:30:14.976: D/dalvikvm(7269): GC_EXTERNAL_ALLOC freed 53K, 48% free 2807K/5379K, external 1687K/2079K, paused 221ms  
11-24 22:30:17.890: D/AndroidRuntime(7269): Shutting down VM  
11-24 22:30:17.890: W/dalvikvm(7269): threadid=1: thread exiting with uncaught exception (group=0x4001e578)  
11-24 22:30:17.921: E/AndroidRuntime(7269): FATAL EXCEPTION: main  
11-24 22:30:17.921: E/AndroidRuntime(7269): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.componenttest/com.example.componenttest.AndroidWebActivity}: java.lang.IllegalStateException: Target host must not be null, or set in parameters.  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.os.Handler.dispatchMessage(Handler.java:99)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.os.Looper.loop(Looper.java:130)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.app.ActivityThread.main(ActivityThread.java:3687)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at java.lang.reflect.Method.invokeNative(Native Method)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at java.lang.reflect.Method.invoke(Method.java:507)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at dalvik.system.NativeStart.main(Native Method)  
11-24 22:30:17.921: E/AndroidRuntime(7269): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters.  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:572)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:292)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at com.example.componenttest.AndroidWebActivity.onCreate(AndroidWebActivity.java:24)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)  
11-24 22:30:17.921: E/AndroidRuntime(7269):     ... 11 more  
  • 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-14T21:12:42+00:00Added an answer on June 14, 2026 at 9:12 pm

    Try changing

     HttpPost httppost = new HttpPost("10.0.2.2/InterfaceTest/GrabMe.php");
    

    to

     HttpPost httppost = new HttpPost("http://10.0.2.2/InterfaceTest/GrabMe.php");
    

    I highly recommend the nuSOAP PHP library for creating a SOAP server. Perhaps try something more specific for the Android client such as this library: https://code.google.com/p/droidsoapclient/. If you are planning to use SOAP that is… =)

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms

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.