我想发现可用的蓝牙设备在后台服务。我被困在“startActivityForResult”部分,因为服务不是活动。请帮助...Android蓝牙搜索服务可用设备
private void CheckBTState() {
// TODO Auto-generated method stub
// Check for Bluetooth support and then check to make sure it is turned on
// If it isn't request to turn it on
// List paired devices
// Emulator doesn't support Bluetooth and will return null
Log.d("check","4");
if (btAdapter.isEnabled()) {
// out.append("\nBluetooth is enabled...");
// Starting the device discovery
btAdapter.startDiscovery();
Log.d("check","5");
} else {
Intent enableBtIntent = new Intent(btAdapter.ACTION_REQUEST_ENABLE);
Log.d("check","6");
STUCK OVER HERE.... DON'T NO HOW TO CALL startActivityForResult IN SERVICE
// ((Activity) context).startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
// activity.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
请与标记你使用(Java中,...)编程语言你的问题。谢谢。 – potame