title: Having trouble passing variable to be displayed on a screen on android
body: <p>I am having trouble with developing my Android application, I am currently using Eclipse and a Phidget RFID. My aim is to display the ID of the RFID in a piece of text on the Android device.</p>
  
  <p>I have managed to display the ID through a println in the following pieces of code.</p>
  
  <pre><code>   package myFood.myFood;
  
  import com.phidgets.*;
  import com.phidgets.event.*;
  public class RFID {
  static String x ="NULL";
  public static final Object main(String args[]) throws Exception {
      RFIDPhidget rfid;
      rfid = new RFIDPhidget();
      rfid.openAny();
  
      //Begin the TagGained event, allowing for users to read the RFID values
      rfid.addTagGainListener(new TagGainListener()
      {
          public void tagGained(TagGainEvent oe)
          {
              Object y = (oe.getValue());
              x= y.toString();
          }
      });
  
      long StartTime,RunTime;
      StartTime=System.currentTimeMillis();
      do{
          RunTime=System.currentTimeMillis();
          if (x.equals("NULL")) {
              //Continue waiting for input
              }
          else
          StartTime = 10000; //Overload the result so the loop ends
      }
      while (RunTime-StartTime&lt;5000);
  
      rfid.close();
      return x;
  }
  
  }
  </code></pre>
  
  <p>and then.</p>
  
  <pre><code>package myFood.myFood;
  
  public class RFIDresult {
  
  public static final Object main(String args[]) throws Exception {
      System.out.println("Results");
  Object x = RFID.main(args);
  System.out.println(x);
  return x;
  }
  }
  </code></pre>
  
  <p>However I want the ID to be displayed in a piece of text so I tried to develop the second piece of code into Android.</p>
  
  <pre><code>package myFood.myFood;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class AddFood  extends Activity {
      /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.addfood);
  
  
  
      Button mybutton = (Button) findViewById(R.id.Button1);
      mybutton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
  
              String[] args = null;
              Object x = null;
              try {
                  x = RFID.main(args);
              } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
      TextView mytext=(TextView)findViewById(R.id.widget96);
      mytext.setText((CharSequence) x);
  
  
      }
  
  
      });
  }
  
  }
  </code></pre>
  
  <p>And this just generates a force close. I am a bit of a novice at this and will appreciate all the advice I get.</p>
  
  <hr>
  
  <p>LogCat Report;</p>
  
  <pre><code>ERROR/AndroidRuntime(519): FATAL EXCEPTION: main
  ERROR/AndroidRuntime(519): java.lang.ExceptionInInitializerError
  ERROR/AndroidRuntime(519):     at myFood.myFood.RFID.main(RFID.java:9)
  ERROR/AndroidRuntime(519):     at myFood.myFood.AddFood$1.onClick(AddFood.java:26)&lt;br/&gt;
  ERROR/AndroidRuntime(519):     at android.view.View.performClick(View.java:2408)
  ERROR/AndroidRuntime(519):     at android.view.View$PerformClick.run(View.java:8816)
  ERROR/AndroidRuntime(519):     at android.os.Handler.handleCallback(Handler.java:587)
  ERROR/AndroidRuntime(519):     at android.os.Handler.dispatchMessage(Handler.java:92)
  ERROR/AndroidRuntime(519):     at android.os.Looper.loop(Looper.java:123)
  ERROR/AndroidRuntime(519):    at     android.app.ActivityThread.main(ActivityThread.java:4627)
  ERROR/AndroidRuntime(519):     at java.lang.reflect.Method.invokeNative(Native Method)
  ERROR/AndroidRuntime(519):     at java.lang.reflect.Method.invoke(Method.java:521)
  ERROR/AndroidRuntime(519):     at om.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  ERROR/AndroidRuntime(519):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  ERROR/AndroidRuntime(519):     at dalvik.system.NativeStart.main(Native Method)
  ERROR/AndroidRuntime(519): Caused by: java.lang.ExceptionInInitializerError: Library phidget21 not found
  ERROR/AndroidRuntime(519): Could not locate the Phidget C library (libphidget21.so).
  ERROR/AndroidRuntime(519): Make sure it is installed, and add it's path to LD_LIBRARY_PATH.
  ERROR/AndroidRuntime(519):     at com.phidgets.Phidget.&lt;clinit&gt;(Phidget.java:34)
  ERROR/AndroidRuntime(519):     ... 13 more
  </code></pre>