title: Im trying to use my HTC camera on my pc Eclipse but im getting errors:
body: <p>This is the content of the file: MainActivity.xml</p>
  
  <pre><code>package com.example.camera_test;
  
  import android.os.Bundle;
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Intent;
  import android.hardware.Camera;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Button button = (Button) findViewById(R.id.button1);
  
          button.setOnClickListener(new OnClickListener()
          {
          @SuppressLint("NewApi") @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
              int i = Camera.getNumberOfCameras();
              TextView age = (TextView) findViewById(R.id.textView1);
              age.setText(i);
              startActivityForResult( intent, 0 );
          }
          });
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p>It was working good I clicked the button and it opened the camera application on my device !
  But as soon as I added this lines:</p>
  
  <pre><code>int i = Camera.getNumberOfCameras();
              TextView age = (TextView) findViewById(R.id.textView1);
              age.setText(i);
  </code></pre>
  
  <p>Im getting the error on my device say nned to force close.</p>
  
  <p>I tried also instead age.setText(I); this:</p>
  
  <pre><code>age.setText(Integer.toString(i));
  </code></pre>
  
  <p>I tried instead of id.textView1 also id.button1 but not working.</p>
  
  <p>This is the content of activity_main.xml file:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:text="@string/hello_world" /&gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:layout_marginRight="45dp"
          android:layout_marginTop="62dp"
          android:text="Activate The Camera" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is the only two files I did changes.</p>