you have to set the premissions for internet. Please read: http://www.itblogs.info/index.php/2009/07/27/android-apps-internet-permission?blog=6
On Mon, Sep 7, 2009 at 5:04 AM, Smelly Eddie <ollit...@gmail.com> wrote: > > Can you access the web with the emulator? I get hostname can not be > resolved errors in similar code as above. > > Do I specify my pc as a proxy or something? > > On Jul 22, 11:16 am, "Justin (Google Employee)" <j...@google.com> > wrote: > > My guess is you are using the emulator here. To the emulator, > > "localhost" will refer to the emulator itself. It is its own virtual > > device, you may consider it its own entity on the network, so you'll > > need to use a proper hostname or IP address for the servlet you want > > to access. > > > > Cheers, > > Justin > > Android Team @ Google > > > > On Jul 22, 6:47 am, Ahmed BEJAOUI <ahmed.bejaoui...@gmail.com> wrote: > > > > > Hello every body, and excuse me for my poor English . > > > > > I'm trying de build an activity which connect to a servlet. But the > command > > > "execute (httpGet)" doesn't work!! i write the permission of internet > in the > > > manifest.xml, but it doesn't work!! > > > heres my code its supposed to connect to the servlet: and thank you > > > > > import java.io.InputStream; > > > > > import org.apache.http.HttpEntity; > > > import org.apache.http.HttpResponse; > > > import org.apache.http.client.HttpClient; > > > import org.apache.http.client.ResponseHandler; > > > import org.apache.http.client.methods.HttpGet; > > > import org.apache.http.impl.client.BasicResponseHandler; > > > import org.apache.http.impl.client.DefaultHttpClient; > > > import org.xml.sax.InputSource; > > > import org.xml.sax.XMLReader; > > > > > import android.app.Activity; > > > import android.os.Bundle; > > > import android.util.Log; > > > import android.widget.EditText; > > > > > public class Connect extends Activity { > > > /** Called when the activity is first created. */ > > > > > private String adresse = new String(" > http://localhost:8080/Test_tomcat/Testt"); > > > private EditText mTitleText; > > > > > public void onCreate(Bundle savedInstanceState) { > > > super.onCreate(savedInstanceState); > > > setContentView(R.layout.main); > > > mTitleText = (EditText) findViewById(R.id.message); > > > connect(adresse); > > > } > > > > > public void connect(String url){ > > > try { > > > HttpClient httpclient = new DefaultHttpClient(); > > > > > // Prepare a request object > > > HttpGet httpget = new HttpGet(url); > > > > > // Execute the request > > > HttpResponse response; > > > try { > > > > > response = httpclient.execute(httpget); > > > > > mTitleText.append("connexion"); > > > > > //Gethold of the response entity > > > HttpEntity entity = response.getEntity(); > > > // If the response does not enclose an entity, there is > no > > > need > > > // to worry about connection release > > > > > if (entity != null) { > > > > mTitleText.append(response.getStatusLine().toString()); > > > } > > > }catch (Exception e) {mTitleText.append("connexion"); > > > } > > > > > httpclient.getConnectionManager().shutdown(); > > > > > } catch (Exception e) { > > > Log.e("Connect", "exception au niveau de l'adresse"); > > > > > } > > > > > } > > > } > > > -- Regards, Michael Leung http://www.itblogs.info http://www.michaelleung.info --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---