title: Hang on button press
body: <p>I've got a weird problem. I've got this android app that should get some data from a URL that leads to a text file. It has 18 lines and one item per line, and looks something like this:</p>
  
  <blockquote>
    <p>Mastercard</p>
    
    <p>name</p>
    
    <p>123456789</p>
    
    <p>1004</p>
    
    <p>56</p>
    
    <p>5000</p>
  </blockquote>
  
  <p>(this is an assignment, all data is obviously fake)</p>
  
  <p>I have this:</p>
  
  <pre><code>public class CreditCard {
  
      //set up method to get and return data as arraylist
      public ArrayList&lt;String&gt; ccArray(){
          ArrayList&lt;String&gt; ccInfo = new ArrayList&lt;String&gt;();
  
          //array set up. time to get data
          try {
              URL urlDat = new URL("url");
              Scanner urlScn = new Scanner(urlDat.openStream());
              while (urlScn.hasNext()){
                  ccArray().add(urlScn.nextLine() + "\n");
              }
  
          }catch (MalformedURLException URLe){
              //handle exception
  
          }
          catch (IOException IOe){
              //handle exception
          }
          return ccInfo;
      }
  }
  </code></pre>
  
  <p>So I can pass the array to the main method (or another method in the class, not sure yet). I have a button that that runs displayCreditCards in the main method:</p>
  
  <pre><code>public void displayCreditCards(View view) throws IOException {
          TextView tv1;
  
          tv1 = (TextView) findViewById(R.id.text_main);
          tv1.setText("Data will appear here");
  
          //create objects to det data and make profiles
          CreditCard ccObj = new CreditCard();
  
  
          tv1.setText(ccObj.ccArray().toString());
  }
  </code></pre>
  
  <p>However, this causes the application to not respond, and I get the wait/close dialog from android. I'm not sure how to interpret the logcat:</p>
  
  <pre><code>10-04 18:27:01.204    9036-9036/? I/art﹕ Not late-enabling -Xcheck:jni (already on)
  10-04 18:27:01.204    9036-9036/? I/art﹕ Late-enabling JIT
  10-04 18:27:01.206    9036-9036/? I/art﹕ JIT created with code_cache_capacity=2MB compile_threshold=1000
  10-04 18:27:01.257    9036-9036/? W/System﹕ ClassLoader referenced unknown path: /data/app/com.example.pat.displaycc-2/lib/x86
  10-04 18:27:01.396    9036-9058/com.example.pat.displaycc D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
  10-04 18:27:01.400    9036-9036/com.example.pat.displaycc D/﹕ HostConnection::get() New Host Connection established 0xad7ad9a0, tid 9036
  10-04 18:27:01.468    9036-9058/com.example.pat.displaycc D/﹕ HostConnection::get() New Host Connection established 0xad7ade40, tid 9058
  10-04 18:27:01.471    9036-9058/com.example.pat.displaycc I/OpenGLRenderer﹕ Initialized EGL, version 1.4
  10-04 18:27:01.520    9036-9058/com.example.pat.displaycc W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  10-04 18:27:01.521    9036-9058/com.example.pat.displaycc W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xad7917c0, error=EGL_SUCCESS
  10-04 18:27:04.841    9036-9036/com.example.pat.displaycc W/art﹕ Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
  10-04 18:27:04.874    9036-9058/com.example.pat.displaycc W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  10-04 18:27:04.874    9036-9058/com.example.pat.displaycc W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xad791c20, error=EGL_SUCCESS
  10-04 18:27:06.138    9036-9058/com.example.pat.displaycc E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab80f0d0
  10-04 18:27:11.564    9036-9058/com.example.pat.displaycc W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  10-04 18:27:11.564    9036-9058/com.example.pat.displaycc W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xad791c00, error=EGL_SUCCESS
  10-04 18:27:13.108    9036-9058/com.example.pat.displaycc E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab80f060
  </code></pre>
  
  <p>I've no idea why it hangs on me, any ideas?</p>