I have default class that I get in new project:
public class start extends Activity {
private static final int REQUEST_ENABLE_BT = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.....
// BluetoothDevice oBT = new BluetoothDevice();
// oBT.enableBluetooth();
......
enable();
.....
}
public void enable (){
Intent enableBtIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
All it does is enables my bluetooth device, and it works. But when I
open commented lines, comment enable()
and add new class from wich I create object, it throws nullpointer
exception. And question is: why it happens?
public class BluetoothDevice extends Activity{
private static final int REQUEST_ENABLE_BT = 1;
public void enableBluetooth (){
Intent enableBtIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
--
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