编译应用程序时没有错误,但是我在Android手机上运行后,应用程序立即崩溃了。有谁可以帮助我?
logcat错误
06-02 17:08:14.925: D/AndroidRuntime(4653): Shutting down VM
06-02 17:08:14.925: W/dalvikvm(4653): threadid=1: thread exiting with uncaught exception (group=0x40b8c930)
06-02 17:08:14.935: E/AndroidRuntime(4653): FATAL EXCEPTION: main
06-02 17:08:14.935: E/AndroidRuntime(4653): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sensormobileaty/com.example.sensormobileaty.MainActivity}: java.lang.NullPointerException
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.ActivityThread.access$600(ActivityThread.java:153)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.os.Looper.loop(Looper.java:137)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.ActivityThread.main(ActivityThread.java:5227)
06-02 17:08:14.935: E/AndroidRuntime(4653): at java.lang.reflect.Method.invokeNative(Native Method)
06-02 17:08:14.935: E/AndroidRuntime(4653): at java.lang.reflect.Method.invoke(Method.java:511)
06-02 17:08:14.935: E/AndroidRuntime(4653): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
06-02 17:08:14.935: E/AndroidRuntime(4653): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
06-02 17:08:14.935: E/AndroidRuntime(4653): at dalvik.system.NativeStart.main(Native Method)
06-02 17:08:14.935: E/AndroidRuntime(4653): Caused by: java.lang.NullPointerException
06-02 17:08:14.935: E/AndroidRuntime(4653): at com.example.sensormobileaty.MainActivity.onCreate(MainActivity.java:28)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.Activity.performCreate(Activity.java:5104)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-02 17:08:14.935: E/AndroidRuntime(4653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
06-02 17:08:14.935: E/AndroidRuntime(4653): ... 11 more
06-02 17:08:26.036: I/Process(4653): Sending signal. PID: 4653 SIG: 9
MainActivity.java
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends ActionBarActivity {
Context myContext = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AlertDialog.Builder builder = new AlertDialog.Builder(myContext);
Button buttonConnect = (Button) findViewById (R.id.connectNew);
buttonConnect.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
startActivity(new Intent(MainActivity.this, ScanForBluetoothDevices.class));
}
});
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
return rootView;
}
}
}
BluetoothServerHelper.java
import java.io.IOException;
import java.util.UUID;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
public class BluetoothServerHelper extends Thread
{
public BluetoothServerHelper (BluetoothDevice mmDevice, Handler mmHandler)
{
this.mmDevice = mmDevice;
this.mmHandler = mmHandler;
}
// IMPORTANT THIS IS SERVICE URL TO CONNECT
UUID mmUUID = UUID.fromString("8d53e166-22d5-48bd-9451-35a8d2eb902d");
BluetoothDevice mmDevice;
Handler mmHandler;
@Override
public void run() {
// IMPORTANT TO CANCEL DISCOVERY BEFORE TRY TO CONNECT
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
BluetoothSocket mmSocket = null;
Message m = new Message();
try
{
mmSocket = mmDevice.createRfcommSocketToServiceRecord(mmUUID);
mmSocket.connect();
} catch (IOException e)
{
m.what = -1; // CONNECTION FAILED
m.obj = e.getMessage(); // SEND FAILURE MESSAGE
if (mmHandler != null)
mmHandler.sendMessage(m);
Log.d("App_Debug", "Failed To connect to UUID");
return;
}
m.what = 1; // CONNECTION SUCESSED
m.obj = mmSocket; // SEND CONNECTED SOCKET
if (mmHandler != null)
mmHandler.sendMessage(m);
}
}
SensorPanel.java
import java.io.DataOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.TextView;
import android.widget.Toast;
public class SensorPanel extends Activity implements SensorEventListener
{
//Button Button_Touch_Left;
//Button Button_Touch_Right;
BluetoothSocket bSocket = null;
DataOutputStream mmOutputStream;
GestureDetector mmGestureDetector;
float [] history = new float[3];
//private float mLastX,mLastY,mLastZ;
private boolean mInitialized = true;
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private final float NOISE = (float) 2.0;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mouse_sensor_panel);
//Button_Touch_Left = (Button) findViewById(R.id.Button_Touch_Left);
//Button_Touch_Right = (Button) findViewById(R.id.Button_Touch_Right);
//View Touch_Panel = (View) findViewById(R.id.View_Touch_Panel);
//Sensor
mInitialized = false;
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
int id = getIntent().getExtras().getInt("BLUETOOTHSOCKET");
// TRY TO CONNECT
Object obj = Globals.getGlobal().getTransferedObject(id);
bSocket = (BluetoothSocket) obj;
if (bSocket == null)
{
Toast.makeText(this, "NULLSOCKET", Toast.LENGTH_SHORT).show();
Log.d("App_Debug", "NullSOCKET");
finish();
return;
}
try
{
mmOutputStream = new DataOutputStream(bSocket.getOutputStream());
} catch (IOException e)
{
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
finish();
return;}
}
//PREPARE
/**Touch_Panel.setOnTOuchListener(new onTouchListener()
{
@Override
public boolean onMoveCommand(float X, float Y)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
v.setPressed(true);
writeMessage(BlueMoProtocol.ACTION_MOUSE_LEFT_BUTTON_DOWN);
return true;
case MotionEvent.ACTION_UP:
v.setPressed(false);
writeMessage(BlueMoProtocol.ACTION_MOUSE_LEFT_BUTTON_UP);
return true;
}
return false;
}
});**/
/**Button_Touch_Right.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
v.setPressed(true);
writeMessage(BlueMoProtocol.ACTION_MOUSE_RIGHT_BUTTON_DOWN);
return true;
case MotionEvent.ACTION_UP:
v.setPressed(false);
writeMessage(BlueMoProtocol.ACTION_MOUSE_RIGHT_BUTTON_UP);
return true;
}
return false;
}
});
mmGestureDetector = new GestureDetector(this, this);
mmGestureDetector.setIsLongpressEnabled(false);
mmGestureDetector.setOnDoubleTapListener(this);
}**/
private void closeBluetoothSockets()
{
if (bSocket != null)
{
try
{
bSocket.close();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public void onDestroy()
{
super.onDestroy();
closeBluetoothSockets();
}
private void showToast(String message)
{
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
private void writeMessage(int msg, int x, int y)
{
try
{
mmOutputStream.writeInt(msg);
mmOutputStream.writeInt(x);
mmOutputStream.writeInt(y);
mmOutputStream.flush();
} catch (IOException e)
{
showToast(e.getMessage());
finish();
LOGd(e.getMessage());
}
}
private void writeMessage(int msg)
{
try
{
mmOutputStream.writeInt(msg);
mmOutputStream.flush();
} catch (IOException e)
{
showToast(e.getMessage());
finish();
LOGd(e.getMessage());
}
}
private void LOGd(String message)
{
Log.d("App_Debug", message);
}
/**@Override
public boolean onDown(MotionEvent arg0)
{
// LOGd("onDown");
return true;
}
@Override
public boolean onFling(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3)
{
// LOGd("onFling");
return false;
}
@Override
public void onLongPress(MotionEvent e)
{
// LOGd("onLongPress");
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
{
// LOGd("onScroll");
// LOGd(e1.getX() + " " + e1.getY() + " || " + e2.getX() + " " +
// e2.getY() + "||" + distanceX + " " + distanceY);
writeMessage(BlueMoProtocol.ACTION_MOVE, (int) distanceX, (int) distanceY);
return true;
}
@Override
public void onShowPress(MotionEvent e)
{
// LOGd("onShowPress");
}
@Override
public boolean onSingleTapUp(MotionEvent e)
{
// LOGd("onSingleTapUp");
return false;
}
// boolean doubleTappMoved = false;
@Override
public boolean onDoubleTap(MotionEvent e)
{
// doubleTappMoved = false;
// LOGd("onDoubleTap");
return true;
}**/
boolean mmDoubleClickConfirmed;
long mmMovesAfterDoubleClick = 0;
float mLastX, mLastY, mLastZ;
final long doubleClickMovesErrorRate = 3;
public boolean onDoubleTapEvent(MotionEvent e)
{
final float xDelta, yDelta;
switch (e.getAction())
{
/**case MotionEvent.ACTION_DOWN:
mmDoubleClickConfirmed = true;
mmMovesAfterDoubleClick = 0;
writeMessage(BlueMoProtocol.ACTION_MOUSE_LEFT_BUTTON_DOWN);
myLastTouchX = e.getX();
myLastTouchY = e.getY();
return true;**/
case MotionEvent.ACTION_MOVE:
mmDoubleClickConfirmed = false;
mmMovesAfterDoubleClick++;
xDelta = mLastX - e.getX();
yDelta = mLastY - e.getY();
writeMessage(BlueMoProtocol.ACTION_MOVE, (int) xDelta, (int) yDelta);
mLastX = e.getX();
mLastY = e.getY();
return true;
/**case MotionEvent.ACTION_UP:
if (mmDoubleClickConfirmed || mmMovesAfterDoubleClick > doubleClickMovesErrorRate)
{
// DoubleClick
writeMessage(BlueMoProtocol.ACTION_MOUSE_LEFT_BUTTON_UP);
writeMessage(BlueMoProtocol.ACTION_SINLE_TAPP);
} else
{
// Drag
writeMessage(BlueMoProtocol.ACTION_MOUSE_LEFT_BUTTON_UP);
}
return true;**/
}
return false;
}
/**@Override
public boolean onSingleTapConfirmed(MotionEvent e)
{
writeMessage(BlueMoProtocol.ACTION_SINLE_TAPP);
// LOGd("onSingleTapConfirmed");
return true;
}**/
protected void onResume() {
super.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
}
protected void onPause() {
super.onPause();
mSensorManager.unregisterListener(this);
}
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
TextView tvX = (TextView) findViewById (R.id.xcoor);
TextView tvY = (TextView) findViewById (R.id.ycoor);
TextView tvZ = (TextView) findViewById (R.id.zcoor);
TextView tvC = (TextView) findViewById (R.id.clickGesture);
float zChanged = history[2] - event.values[2];
float threshold = 3.0f;
history[2] = event.values[2];
float X = event.values [0];
float Y = event.values [1];
float Z = event.values [2];
if (!mInitialized) {
mLastX = X;
mLastY = Y;
mLastZ = Z;
tvX.setText("0.00");
tvY.setText("0.00");
tvZ.setText("0.00");
mInitialized = true;
} else {
float deltaX = Math.abs(mLastX - X);
float deltaY = Math.abs(mLastY - Y);
float deltaZ = Math.abs(mLastZ - Z);
if (deltaX < NOISE) deltaX = (float) 0.0;
if (deltaY < NOISE) deltaY = (float) 0.0;
if (deltaZ < NOISE) deltaZ = (float) 0.0;
mLastX = X;
mLastY = Y;
mLastZ = Z;
tvX.setText(Float.toString(deltaX));
tvY.setText(Float.toString(deltaY));
tvZ.setText(Float.toString(deltaZ));
writeMessage(BlueMoProtocol.ACTION_MOVE);
} if (zChanged > threshold) {
tvC.setText("1");
writeMessage(BlueMoProtocol.ACTION_SINGLE_TAP);
} else if (zChanged < threshold) {
tvC.setText("0");
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
}
ScanForBluetoothDevices.java
import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class ScanForBluetoothDevices extends Activity
{
ArrayList<BluetoothDevice> mmBDevices;
ArrayAdapter<String> mmListviewAdapter;
Button mmBtnScann;
Activity mmContext = this;
private Button mmBtnCancal;
public Context getThisContext()
{
return mmContext;
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.scan_bluetooth_devices);
setTitle("Please start scann ");
mmBDevices = new ArrayList<BluetoothDevice>();
mmListviewAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
mmBtnCancal = (Button) findViewById(R.id.bCancel);
mmBtnScann = (Button) findViewById(R.id.bScan);
ListView lstDiscoveredDevices = (ListView) findViewById(R.id.listView1);
// Register broadcast receivers
IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
this.registerReceiver(mmBluetoothBroadcastReciever, filter);
filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mmBluetoothBroadcastReciever, filter);
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
this.registerReceiver(mmBluetoothBroadcastReciever, filter);
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mmBluetoothBroadcastReciever, filter);
lstDiscoveredDevices.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, final int position, long arg3)
{
// ask if connect
AlertDialog.Builder builder = new AlertDialog.Builder(getThisContext());
builder.setCancelable(true);
builder.setTitle("Connect ?");
// builder.setInverseBackgroundForced(true);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
// Get BlueTooth device to connect
BluetoothDevice bDevice = mmBDevices.get(position);
@Override
public void onClick(final DialogInterface dialog, int which)
{
// Display Progress while trying to connect remote
// device
final ProgressDialog pDialog = ProgressDialog.show(getThisContext(), "Status", "Connecting ...");
pDialog.setCancelable(false);
// handler which gets notified when connection status
// changes
Handler handler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
switch (msg.what)
{
case -1: // fail
Toast.makeText(getApplicationContext(), (String) msg.obj, Toast.LENGTH_LONG).show();
if (pDialog.isShowing())
pDialog.dismiss();
break;
case 1: // success
if (pDialog.isShowing())
pDialog.dismiss();
int objectID = Globals.getGlobal().putTransferObject(msg.obj);
finish();
Intent intent = new Intent(getThisContext(), SensorPanel.class);
intent.putExtra("BLUETOOTHSOCKET", objectID);
startActivity(intent);
break;
}
}
};
// Try to connect to remote device new
(new BluetoothServerHelper(bDevice, handler)).start();
}
});
builder.setNegativeButton("No", null);
// CREATE AND SHOW ALERT DIALOG
AlertDialog alert = builder.create();
alert.show();
}
});
lstDiscoveredDevices.setAdapter(mmListviewAdapter);
mmBtnScann.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
BluetoothAdapter bAdapter = BluetoothAdapter.getDefaultAdapter();
if (!bAdapter.isEnabled())//enable bluetooth
{
//Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
//startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
startActivity(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE));
} else
{
bAdapter.startDiscovery();
}
}
});
mmBtnCancal.setEnabled(false);
mmBtnCancal.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
}
});
}
@Override
protected void onDestroy()
{
super.onDestroy();
this.unregisterReceiver(mmBluetoothBroadcastReciever);
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
}
BroadcastReceiver mmBluetoothBroadcastReciever = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (action == BluetoothAdapter.ACTION_STATE_CHANGED)
{
final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
switch (state)
{
case BluetoothAdapter.STATE_ON:
showToast("Bluetooth is On");
BluetoothAdapter.getDefaultAdapter().startDiscovery();
break;
}
} else if (action.equals(BluetoothDevice.ACTION_FOUND))
{
BluetoothDevice bDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Log.d("App_Debug", "Device found: " + bDevice.getAddress());
mmBDevices.add(bDevice);
mmListviewAdapter.add(bDevice.getName() + "(" + bDevice.getAddress() + ")");
mmListviewAdapter.notifyDataSetChanged();
} else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED))
{
mmBtnCancal.setEnabled(true);
mmBtnScann.setEnabled(false);
mmListviewAdapter.clear();
mmBDevices.clear();
mmListviewAdapter.notifyDataSetChanged();
setTitle("Scanning...");
} else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED))
{
setTitle("Scann finished");
mmBtnScann.setEnabled(true);
mmBtnCancal.setEnabled(false);
}
}
private void showToast(String message)
{
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
Log.d("App_Debug", message);
}
};
}
Globals.java
import java.util.Hashtable;
public final class Globals {
private static Globals mmGlobal = new Globals();
Hashtable<Integer, Object> mmObjectsToTransfer = new Hashtable<Integer, Object>();
static int mmSampleIdGenerator = Integer.MIN_VALUE;
private Globals(){
}
public static Globals getGlobal() {
return mmGlobal;
}
private int nextID() {
return mmSampleIdGenerator++;
}
public int putTransferObject(Object obj)
{
int id = nextID();
mmObjectsToTransfer.put(id, obj);
return id;
}
public Object getTransferedObject(int id)
{
return mmObjectsToTransfer.remove(id);
}
}
BlueMoProtocol.java
public final class BlueMoProtocol
{
public static final int ACTION_MOVE = -99901;
public static final int ACTION_SINGLE_TAP = -99903;
public static final int STATIC_DISCONNECT = -99906;
}
fragment_main.xml
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.sensormobileaty.MainActivity$PlaceholderFragment" >
<Button
android:id="@+id/connectNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="@string/connect" />
</RelativeLayout>
mouse_sensor_panel.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/sensorCoordinate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/coordinate"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/sensorCoordinate" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/x_axis" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/y_axis" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/z_axis" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/click" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tableLayout1"
android:layout_toRightOf="@+id/tableLayout1" >
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/xcoor"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/ycoor"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="@+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/zcoor"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="@+id/tableRow8"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/clickGesture"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</RelativeLayout>
scan_bluetooth_devices.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvPD"
android:layout_above="@+id/bScan" >
</ListView>
<Button
android:id="@+id/bScan"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="@string/scan" />
<TextView
android:id="@+id/tvPD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/paired_devices" />
<Button
android:id="@+id/bCancel"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="@string/cancel" />
</RelativeLayout>