Greetings all,
I'm writing a remote control app for a touchscreen jukebox pc. My jukebox
has an http control mechanism where you pass commands to it like so:
http://192.168.1.2:6969?playlist (returns JSON encoded playlist)

In my android app, I'm using httpGet to connect to the jukebox server,
however when I try to connect, it throws an IOException and the log shows:
06-29 18:03:52.579: WARN/System.err(5348): java.net.UnknownHostException:
Host is unresolved: http://192.168.1.2:6969

I'm running the app on my actual phone, not on the emulator, and I am
connected to my wifi, so I decided to test with http://www.google.com, and I
get the same "Host is unresolved" result.
I CAN, however, connect to both url's using the browser on the phone with no
problem.

What am I doing wrong?

Thanks,
Keith

Source code below:
-----------------------------------------------------------------------------------
package com.kgreene.stylusremote;

import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

@SuppressWarnings("unused")
public class stylusremote extends Activity {
    private static final String TAG = "Stylusremote";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Perform action on clicks
             try {
// String junk = doGet( "http://192.168.1.2";, 6969 );
String junk = doGet( "http://www.google.com";, 80 );
} catch (ClientProtocolException e) {
Toast.makeText(stylusremote.this, "ClientProtocolException",
Toast.LENGTH_SHORT).show();
e.printStackTrace();
} catch (IOException e) {
Toast.makeText(stylusremote.this, "IOException", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
// Toast.makeText(stylusremote.this, junk, Toast.LENGTH_SHORT).show();
            }
        });
    }
    public static String doGet(String url, int port) throws
ClientProtocolException, IOException
    {
     HttpHost target = new HttpHost(url, port);
     HttpGet get = new HttpGet("?playlist");
     String result = null;
     HttpEntity entity = null;
     HttpClient client = new DefaultHttpClient();
        HttpResponse response=client.execute(target, get);
        entity = response.getEntity();
        result = EntityUtils.toString(entity);
       return result;
    }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to