0

我在笔记本电脑上运行 glassfish。如何从真正的 android 设备或模拟器访问它

4

1 回答 1

0

If you want to access it using an HTTPURLConnection you have simply:

        HttpURLConnection con = (HttpURLConnection) ( new URL(url)).openConnection();
        con.setRequestMethod("POST");
        con.setDoInput(true);
        con.setDoOutput(true);
        con.connect();

Remember that if you use your emulator localhost (127.0.0.1) corresponds to 10.0.2.2. Once you have your connection open you can read and write using InputStream or Outpustream.

If you use a real device be sure your glashfish server is visible from your smartphone.

于 2013-05-13T07:54:59.920 回答