I've been playing around a bit with restlet, and so far I like it :)  I'm
having some trouble getting a restlet android client off the ground, though.

Right now a have a very simple restlet server running under JSE.  All it
does is expose a root resource (which for the moment is just a line of text)
via the GET method.  I can get consume the resource with a browser, and also
with a simple restlet client running in the console.  I have modified the
code for the JSE client to try to connect from an android emulator but I
can't get it to work:

package mypackage;

import android.app.Activity;
import android.os.Bundle;

import android.widget.TextView;

import org.restlet.resource.ClientResource;
import org.restlet.representation.Representation;

public class MyActivity extends Activity {

    @Override
    public void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );

        ClientResource res = new ClientResource( "http://server-ip:8111/"; );
        Representation rep = res.get();
        
        TextView tv = new TextView( this );
        try {
                tv.setText( rep.getText() );
        }
        catch ( Exception ex ) {
                tv.setText( "Exception: " + ex.getMessage() );
        }
        setContentView( tv );
        
    }

}

Notes:

(1) The built-in browser on the android emulator can connect to the web
service and retrieve the text.
(2) The project Manifest.xml file has been modified to enable the
uses-permission INTERNET.

Any ideas what I might be doing wrong?

Thanks in advance,

Mike.

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Trouble-creating-restlet-client-on-android-tp6399993p6399993.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2747047

Reply via email to