Get xml from a php webservice url using android

前端 未结 2 998
南方客
南方客 2020-12-22 00:17

I want to read a xml from a service url, I wrote the code, my url is ok, seen from browser,

    public String getXML(){
    String line = null;
    try {
            


        
相关标签:
2条回答
  • 2020-12-22 01:01

    I am sure that your using emulator.

    Andriod emulator is separate virtual machine by itself. If we provide localhost/127.0.0.1 as a hostname, then emulator will try to search url within its environment. To avoid this problem, we need to provide the ipaddress of local machine.

    Pls note that machine name as a hostname will also give problem.

    127.0.0.1 refers to localhost in the Emulator, not your machine.
    
    Use 10.0.2.2 to connect to your host machine.
    
    0 讨论(0)
  • 2020-12-22 01:08

    in your manifest.xml add this description

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    
    0 讨论(0)
提交回复
热议问题