summaryrefslogtreecommitdiff
path: root/android/sdremote
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2012-09-03 12:43:58 +0200
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2012-09-03 12:44:39 +0200
commitcb6d2ed236bd8907d135ca6c292553fb4691f6d4 (patch)
treebc37c850e2eac8111d012b2d943c71e058a4b951 /android/sdremote
parente11ae67cdcb3c9a98019dc6ec49801c495243663 (diff)
Repeat bluetooth discovery periodically.
Change-Id: I2cccc3118a06b2202a249ae8ed116d2c3bc85395
Diffstat (limited to 'android/sdremote')
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java55
1 files changed, 12 insertions, 43 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
index b001d1a862c6..dedce232d4db 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
@@ -11,6 +11,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.os.Handler;
import android.support.v4.content.LocalBroadcastManager;
public class BluetoothFinder {
@@ -18,8 +19,6 @@ public class BluetoothFinder {
// TODO: add removal of cached items
private Context mContext;
- private static final String CHARSET = "UTF-8";
-
BluetoothAdapter mAdapter;
public BluetoothFinder(Context aContext) {
@@ -64,8 +63,6 @@ public class BluetoothFinder {
@Override
public void onReceive(Context context, Intent aIntent) {
// TODO Auto-generated method stub
- System.out.print("Received intent<<<");
- System.out.println(aIntent.getAction());
if (aIntent.getAction().equals(BluetoothDevice.ACTION_FOUND)) {
BluetoothDevice aDevice = (BluetoothDevice) aIntent.getExtras()
.get(BluetoothDevice.EXTRA_DEVICE);
@@ -79,45 +76,17 @@ public class BluetoothFinder {
CommunicationService.MSG_SERVERLIST_CHANGED);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
aNIntent);
- // System.out.println("Found " + aDevice.getName());
- // try {
- // // "f36d0a20-e876-11e1-aff1-0800200c9a66"
- // BluetoothSocket aSocket = aDevice
- // .createRfcommSocketToServiceRecord(UUID
- // .fromString("00001101-0000-1000-8000-00805F9B34FB"));
- // aSocket.connect();
- // } catch (IOException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // System.out.println("Fallback");
- // Method m;
- // try {
- // m = aDevice.getClass().getMethod("createRfcommSocket",
- // new Class[] { int.class });
- // BluetoothSocket aFSocket = (BluetoothSocket) m.invoke(
- // aDevice, 1);
- //
- // mAdapter.cancelDiscovery();
- // aFSocket.connect();
- // } catch (NoSuchMethodException e1) {
- // // TODO Auto-generated catch block
- // e1.printStackTrace();
- // } catch (IllegalArgumentException e1) {
- // // TODO Auto-generated catch block
- // e1.printStackTrace();
- // } catch (IllegalAccessException e1) {
- // // TODO Auto-generated catch block
- // e1.printStackTrace();
- // } catch (InvocationTargetException e1) {
- // // TODO Auto-generated catch block
- // e1.printStackTrace();
- // } catch (IOException e1) {
- // // TODO Auto-generated catch block
- // e1.printStackTrace();
- // }
- // System.out.println("Fallback complete");
- //
- // }
+ } else if (aIntent.getAction().equals(
+ BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
+ // Start discovery again after a small delay.
+ Handler aHandler = new Handler();
+ aHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ mAdapter.startDiscovery();
+ }
+ }, 1000 * 15);
+ ;
}
}