title: Why I am getting the Network main thread exception for accessing a spreadsheet?
body: <p>I'm getting many exceptions like NetworkMainthread. And yes I have followed the steps from <a href="https://developers.google.com/google-apps/spreadsheets/" rel="nofollow">https://developers.google.com/google-apps/spreadsheets/</a></p>
  
  <pre><code>public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      String USERNAME = "xyz@gmail.com";
      String PASSWORD = "rrrrrrr";
  
  
      URL SPREADSHEET_FEED_URL = null;
      try {
          SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
          /*https://spreadsheets.google.com/feeds/spreadsheets/public/full");*/
      } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration-v1");
      service.setProtocolVersion(SpreadsheetService.Versions.V3);
      try {
          service.setUserCredentials(USERNAME, PASSWORD);
      } catch (AuthenticationException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  
      SpreadsheetFeed feed = null;
      try {
          feed = service.getFeed(SPREADSHEET_FEED_URL,SpreadsheetFeed.class);
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (ServiceException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      List&lt;SpreadsheetEntry&gt; spreadsheets = feed.getEntries();
      SpreadsheetEntry spreadsheet = spreadsheets.get(0);
      System.out.println(spreadsheet.getTitle().getPlainText());
      WorksheetFeed worksheetFeed = null;
      try {
          worksheetFeed = service.getFeed(
                  spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
      } catch (IOException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      } catch (ServiceException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      }
          List&lt;WorksheetEntry&gt; worksheets = worksheetFeed.getEntries();
          WorksheetEntry worksheet = worksheets.get(0);
  
          URL listFeedUrl = worksheet.getListFeedUrl();
          ListFeed listFeed = null;
          try {
              listFeed = service.getFeed(listFeedUrl, ListFeed.class);
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (ServiceException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
         List&lt;ListEntry&gt; list = listFeed.getEntries();
  
          for (ListEntry row : list) {
              System.out.println(row.getTitle().getPlainText() + "\t" + row.getPlainTextContent());
          }
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  </code></pre>
  
  <p>}</p>