I am trying to register to a BroadcastReceiver in order to obtain the
results of a Bluetooth Inquiry. The problem I have is, at least as I
know, is not possible to use the registerService function if my class
does not extend of Activity or Context.
The definition of my class is like this:
public class BluetoothDiscovery extends Discovery implements Runnable
And I create my broadcast receiver like this:
mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
}
}
};
So, when I try to register the service I do:
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, new
IntentFilter(BluetoothDevice.ACTION_FOUND));
I have an error in this last sentence because the class does not know
what registerReceiver means.
What can I do¿¿¿
Thanks
rk
Try to keep the instance of his activity (at boot) into a static
variable.
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.