1. Are you ready for the Galaxy S20? Here is everything we know so far!

Permission Exception when reading remote files

Discussion in 'Android Development' started by hshhbd, Nov 4, 2010.

  1. hshhbd

    hshhbd Lurker
    Thread Starter

    I was trying to read a xml file remotely but keep getting the java.net.SocketException: Permission denied exception. I tried the same thing within a normal java application and it works.

    Here is the code:
    try
    {
    URL url = new URL("http://rss.weather.com/rss/national/rss_nwf_rss.xml?cm_ven=NWF&cm_cat=rss&par=NWF_rss");
    InputStream input = url.openStream();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }

    I was doing it in a Android Emulator, maybe that's the cause?

    Thanks very much in advance for any replies.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. jonbonazza

    jonbonazza Android Expert

    Did you enable the GSM Modem when creating the AVD?
     
  3. hshhbd

    hshhbd Lurker
    Thread Starter

    Thanks for your reply. Actually I have just solved the problem. It's something to do with the manifest file. To solve the problem, the following line will need to be added.
    <uses-permission android:name="android.permission.INTERNET"/>

    This enables your android application talking to files on remote servers.
     
Loading...

Share This Page

Loading...