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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:10:31+00:00 2026-06-16T17:10:31+00:00

I’m really new to Android and Java, I have decent experience in PHP &

  • 0

I’m really new to Android and Java, I have decent experience in PHP & Web programming. I want to send some POST data from android to my server (Localhost), and display it in the server.

[EDIT UPDATED LOG]

Here’s my code:

public class NewUserActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_user);
}

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

public void addNewUser(View view) {

    EditText em = (EditText) findViewById(R.id.email);
    EditText na = (EditText) findViewById(R.id.name);
    EditText pa = (EditText) findViewById(R.id.pass);

    String e = em.getText().toString();
    String n = na.getText().toString();
    String p = pa.getText().toString();

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://localhost/mapptor/register.php");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("email", e));
        nameValuePairs.add(new BasicNameValuePair("name", n));
        nameValuePairs.add(new BasicNameValuePair("pass",p));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        @SuppressWarnings("unused")
        HttpResponse response = httpclient.execute(httppost);

    } catch (ClientProtocolException exc) {
        Log.d("T1", "HERE1");
    } catch (IOException exc) {
        Log.d("T2", "HERE2");
    }
}

The problem is, this keeps getting FORCE CLOSED when I run it (emulator).

So I kind of went through the log:

12-30 13:36:54.940: I/ActivityManager(62): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.mapptor.android/.NewUserActivity } from pid 130
12-30 13:36:54.980: I/ActivityManager(62): Start proc com.mapptor.android for activity com.mapptor.android/.NewUserActivity: pid=616 uid=10036 gids={}
12-30 13:36:56.110: I/ActivityManager(62): Displayed com.mapptor.android/.NewUserActivity: +1s133ms
12-30 13:37:02.660: W/KeyCharacterMap(116): No keyboard for id 0
12-30 13:37:02.670: W/KeyCharacterMap(116): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
12-30 13:37:04.240: W/KeyCharacterMap(616): No keyboard for id 0
12-30 13:37:04.240: W/KeyCharacterMap(616): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
12-30 13:37:04.640: D/dalvikvm(116): GC_EXTERNAL_ALLOC freed 254K, 58% free 3570K/8327K, external 7069K/7413K, paused 212ms
12-30 13:37:04.761: W/KeyCharacterMap(116): No keyboard for id 0
12-30 13:37:04.761: W/KeyCharacterMap(116): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
12-30 13:37:08.690: D/AndroidRuntime(616): Shutting down VM
12-30 13:37:08.690: W/dalvikvm(616): threadid=1: thread exiting with uncaught exception (group=0x40015560)
12-30 13:37:08.710: E/AndroidRuntime(616): FATAL EXCEPTION: main
12-30 13:37:08.710: E/AndroidRuntime(616): java.lang.IllegalStateException: Could not execute method of the activity
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.view.View$1.onClick(View.java:2144)
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.view.View.performClick(View.java:2485)
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.view.View$PerformClick.run(View.java:9080)
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.os.Handler.handleCallback(Handler.java:587)
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.os.Handler.dispatchMessage(Handler.java:92)
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.os.Looper.loop(Looper.java:123)
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.app.ActivityThread.main(ActivityThread.java:3683)
12-30 13:37:08.710: E/AndroidRuntime(616):  at java.lang.reflect.Method.invokeNative(Native Method)
12-30 13:37:08.710: E/AndroidRuntime(616):  at java.lang.reflect.Method.invoke(Method.java:507)
12-30 13:37:08.710: E/AndroidRuntime(616):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-30 13:37:08.710: E/AndroidRuntime(616):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-30 13:37:08.710: E/AndroidRuntime(616):  at dalvik.system.NativeStart.main(Native Method)
12-30 13:37:08.710: E/AndroidRuntime(616): Caused by: java.lang.reflect.InvocationTargetException
12-30 13:37:08.710: E/AndroidRuntime(616):  at java.lang.reflect.Method.invokeNative(Native Method)
12-30 13:37:08.710: E/AndroidRuntime(616):  at java.lang.reflect.Method.invoke(Method.java:507)
12-30 13:37:08.710: E/AndroidRuntime(616):  at android.view.View$1.onClick(View.java:2139)
12-30 13:37:08.710: E/AndroidRuntime(616):  ... 11 more
12-30 13:37:08.710: E/AndroidRuntime(616): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters.
12-30 13:37:08.710: E/AndroidRuntime(616):  at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:572)
12-30 13:37:08.710: E/AndroidRuntime(616):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:292)
12-30 13:37:08.710: E/AndroidRuntime(616):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
12-30 13:37:08.710: E/AndroidRuntime(616):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
12-30 13:37:08.710: E/AndroidRuntime(616):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
12-30 13:37:08.710: E/AndroidRuntime(616):  at com.mapptor.android.NewUserActivity.addNewUser(NewUserActivity.java:61)
12-30 13:37:08.710: E/AndroidRuntime(616):  ... 14 more
12-30 13:37:08.730: W/ActivityManager(62):   Force finishing activity com.mapptor.android/.NewUserActivity

I’m unable to debug this.
What could be the issue?

Thank you. 🙂

  • 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-16T17:10:33+00:00Added an answer on June 16, 2026 at 5:10 pm
    HttpPost httppost = new HttpPost("localhost/mapptor/register.php");
    

    Exception message is:

    Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters.
    

    Based on message it is easy to figure out that:

    localhost/mapptor/register.php

    is not a valid url. Enter valid HTTP url here. It would be something like:

    http://localhost:port/mapptor/register.php
    

    You can make sure that url is valid by accessing it from any web browser.

    EDIT:

    While working with android localhost lookup you need to use 10.0.2.2 instead of localhost in url. 10.0.2.2 represents loopback IP of the machine and 127.0.0.1 represents loopback IP of the emulator.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.