Using setText results in Source not found
<p>I have a program that logs USB data to a file that I create and it works fine.
I am trying to display some of this data using setText but the setText executes once correctly and then the next time it is called I get a Source not found crash.</p>

<p>I am saving the USB data to my file in this Run:</p>

<pre><code>    @Override
public void run() {
    ByteBuffer buffer = ByteBuffer.allocate(64);
    UsbRequest request = new UsbRequest();
    request.initialize(mConnection, mEndpointIntr);
    while (true) {
        request.queue(buffer, 64);
        if (mConnection.requestWait() == request) {
            znum.setText("help"); 
            savetofile("GOT data " + System.currentTimeMillis());
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
        } else {
            Log.e(TAG, "requestWait failed, exiting");
            savetofile("10 requestWait failed, exiting");
            break;
        }
    }
}
</code></pre>

<p>If I rem out the setText line in the above, the program runs happily, saving my data to a file.
When I run the code as above, the program crashes and I get a Source not found indication.</p>

<p>If I start the program with a break on the savetofile line, the layout gets updated with tvZnum set to help just fine.</p>

<p>Then I step thru the code and get back to the setText line.  </p>

<p>All is fine until I execute setText the second time, then it crashes.</p>

<p>It seems to be at android.view.ViewRootImpl.checkThread() line 4077 when it crashes.  I tried to add a screen capture image to my post here but I don't have enough reputation points yet.</p>

<p>I declare:</p>

<pre><code>    TextView znum;
</code></pre>

<p>And have this in OnCreate:</p>

<pre><code>    znum = (TextView) findViewById(R.id.tvZnum);
</code></pre>

<p>And tvZnum shows up fine in the launcher and R.</p>

<p>I know the answer must be simple but simple me can't figure it out.</p>

<p>Any ideas out there?</p>

<p>Thanks,
Dale</p>

<p>Edit: Here is logCat (Greek to me and I couldn't figure out how to format it here):</p>

<blockquote>
  <p>I/dalvikvm( 1529): threadid=3: reacting to signal 3</p>
  
  <p>I/dalvikvm( 1529): Wrote stack traces to '/data/anr/traces.txt'</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/Process (  167): Sending signal. PID: 1529 SIG: 3</p>
  
  <p>I/dalvikvm( 1529): threadid=3: reacting to signal 3</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/dalvikvm( 1529): Wrote stack traces to '/data/anr/traces.txt'</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/Process (  167): Sending signal. PID: 1529 SIG: 3</p>
  
  <p>I/dalvikvm( 1529): threadid=3: reacting to signal 3</p>
  
  <p>I/dalvikvm( 1529): Wrote stack traces to '/data/anr/traces.txt'</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/Process (  167): Sending signal. PID: 1529 SIG: 3</p>
  
  <p>I/dalvikvm( 1529): threadid=3: reacting to signal 3</p>
  
  <p>I/dalvikvm( 1529): Wrote stack traces to '/data/anr/traces.txt'</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/System.out( 1529): waiting for debugger to settle...</p>
  
  <p>I/System.out( 1529): debugger has settled (1359)</p>
  
  <p>I/Process (  167): Sending signal. PID: 1529 SIG: 3</p>
  
  <p>I/dalvikvm( 1529): threadid=3: reacting to signal 3</p>
  
  <p>I/dalvikvm( 1529): Wrote stack traces to '/data/anr/traces.txt'</p>
  
  <p>D/dalvikvm( 1529): threadid=1: still suspended after undo (sc=1 dc=1)</p>
  
  <p>D/ProMeasure2DActivity( 1529): intent: Intent {
  act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
  flg=0x10000000
  cmp=com.android.missilelauncher/.MissileLauncherActivity }</p>
  
  <p>D/ProMeasure2DActivity( 1529): setDevice
  UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=1240,mProductId=63,mClass=0,mSubclass=0,mProtocol=0,mInterfaces=[Landroid.os.Parcelable;@40f9e3b0]</p>
  
  <p>D/ProMeasure2DActivity( 1529): open SUCCESS</p>
  
  <p>D/UsbRequestJNI( 1529): init</p>
  
  <p>D/ViewRootImpl( 1529): pckname = com.android.missilelauncher</p>
  
  <p>I/Process (  167): Sending signal. PID: 1529 SIG: 3</p>
  
  <p>I/dalvikvm( 1529): threadid=3: reacting to signal 3</p>
  
  <p>D/dalvikvm( 1529): threadid=11: still suspended after undo (sc=1 dc=1)</p>
  
  <p>I/dalvikvm( 1529): Wrote stack traces to '/data/anr/traces.txt'</p>
  
  <p>I/ActivityManager(  167): Displayed
  com.android.missilelauncher/.MissileLauncherActivity: +3s791ms</p>
  
  <p>I/ActivityManager(  167): No longer want com.android.email (pid 1266):
  hidden #16</p>
  
  <p>D/Finsky  (  696): [1] 5.onFinished: Installation state replication
  succeeded.</p>
</blockquote>
