This is my Code, Please tell me if i am missing something...i am Stuck
with this for more then 2 weeks now, any help will be very
appreciated.
it's short please have a look on it.
package android.mgo.helloandroid;
import java.util.Set;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
public class UIdrawingActivity extends Activity implements
OnClickListener {
/** Called when the activity is first created. */
Button startdetectingbtn;
Button clearbtn;
EditText roomnumbertext;
EditText bluetoothdetect;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bluetoothdetect = (EditText)findViewById(R.id.detectedsignal);
roomnumbertext =
(EditText)findViewById(R.id.roomnumbertextedit);
clearbtn = (Button)findViewById(R.id.clearbtn);
View startdetectingbtn = findViewById(R.id.startdetectingbtn);
startdetectingbtn.setOnClickListener(this);
clearbtn.setOnClickListener(new OnClickListener() {
// clear the text boxes
@Override
public void onClick(View v) {
roomnumbertext.setText("");
bluetoothdetect.setText("");
}
});}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.startdetectingbtn:
EditText bluetoothtext =
(EditText)findViewById(R.id.detectedsignal);
// Getting the Bluetooth adapter
BluetoothAdapter adapter =
BluetoothAdapter.getDefaultAdapter();
bluetoothtext.append("\nAdapter: " + adapter);
// Check for Bluetooth support in the first place
// Emulator doesn't support Bluetooth and will return null
if(adapter==null) {
bluetoothtext.append("\nBluetooth NOT supported. Aborting.");
return;
}
else{
// Starting the device discovery
bluetoothtext.append("\nStarting discovery...");
adapter.startDiscovery();
bluetoothtext.append("\nDone with discovery...");
// Listing paired devices
bluetoothtext.append("\nDevices Paired:");
Set<BluetoothDevice> devices =
adapter.getBondedDevices();
for (BluetoothDevice device : devices)
{
bluetoothtext.append("\nFound device: " +
device);
}
Intent i = new Intent(this, UIdrawingActivity.class);
startActivity(i);
}
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en