1. Check out our companion app, Forums for Android! Download from Google Play

Permission Exception when reading remote files

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

  1. hshhbd

    hshhbd New Member
    Thread Starter
    5

    Nov 4, 2010
    2
    0
    5
    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.
     

    Advertisement

  2. jonbonazza

    jonbonazza Well-Known Member
    163

    Jul 13, 2010
    1,934
    459
    163
    Male
    Did you enable the GSM Modem when creating the AVD?
     
  3. hshhbd

    hshhbd New Member
    Thread Starter
    5

    Nov 4, 2010
    2
    0
    5
    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.
     

Share This Page

Loading...