initial commit
authorbongo <bongo@bird.localdomain>
Tue, 27 Sep 2011 17:56:15 +0000 (19:56 +0200)
committerbongo <bongo@bird.localdomain>
Tue, 27 Sep 2011 17:56:15 +0000 (19:56 +0200)
32 files changed:
.classpath [new file with mode: 0644]
.project [new file with mode: 0644]
AndroidManifest.xml [new file with mode: 0644]
bin/HQBeamer.apk [new file with mode: 0644]
bin/classes.dex [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$1.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$2.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$3.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$4.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$5.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$6.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$7.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$8.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectThread.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectedThread.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/HQBeamerActivity.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/R$attr.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/R$drawable.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/R$id.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/R$layout.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/R$string.class [new file with mode: 0644]
bin/de/bongo/android/hqbeamer/R.class [new file with mode: 0644]
bin/resources.ap_ [new file with mode: 0644]
default.properties [new file with mode: 0644]
gen/de/bongo/android/hqbeamer/R.java [new file with mode: 0644]
proguard.cfg [new file with mode: 0644]
res/drawable-hdpi/icon.png [new file with mode: 0644]
res/drawable-ldpi/icon.png [new file with mode: 0644]
res/drawable-mdpi/icon.png [new file with mode: 0644]
res/layout/main.xml [new file with mode: 0644]
res/values/strings.xml [new file with mode: 0644]
src/de/bongo/android/hqbeamer/HQBeamerActivity.java [new file with mode: 0644]

diff --git a/.classpath b/.classpath
new file mode 100644 (file)
index 0000000..609aa00
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="src" path="gen"/>
+       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..75f10a0
--- /dev/null
+++ b/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>HQBeamer</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..6c16b07
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="de.bongo.android.hqbeamer"
+      android:versionCode="1"
+      android:versionName="1.0">
+    <uses-sdk android:minSdkVersion="8" />
+    <uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
+
+    <application android:icon="@drawable/icon" android:label="@string/app_name">
+        <activity android:name=".HQBeamerActivity"
+                  android:label="@string/app_name" android:theme="@android:style/Theme.Wallpaper.NoTitleBar">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+    </application>
+</manifest>
\ No newline at end of file
diff --git a/bin/HQBeamer.apk b/bin/HQBeamer.apk
new file mode 100644 (file)
index 0000000..70c8452
Binary files /dev/null and b/bin/HQBeamer.apk differ
diff --git a/bin/classes.dex b/bin/classes.dex
new file mode 100644 (file)
index 0000000..c505cf2
Binary files /dev/null and b/bin/classes.dex differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$1.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$1.class
new file mode 100644 (file)
index 0000000..6201462
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$1.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$2.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$2.class
new file mode 100644 (file)
index 0000000..68091d9
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$2.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$3.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$3.class
new file mode 100644 (file)
index 0000000..1dfbf45
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$3.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$4.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$4.class
new file mode 100644 (file)
index 0000000..21a0258
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$4.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$5.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$5.class
new file mode 100644 (file)
index 0000000..c97ecad
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$5.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$6.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$6.class
new file mode 100644 (file)
index 0000000..4587581
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$6.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$7.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$7.class
new file mode 100644 (file)
index 0000000..14171b9
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$7.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$8.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$8.class
new file mode 100644 (file)
index 0000000..2bd5596
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$8.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectThread.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectThread.class
new file mode 100644 (file)
index 0000000..3e84ce5
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectThread.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectedThread.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectedThread.class
new file mode 100644 (file)
index 0000000..eccdf7d
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity$ConnectedThread.class differ
diff --git a/bin/de/bongo/android/hqbeamer/HQBeamerActivity.class b/bin/de/bongo/android/hqbeamer/HQBeamerActivity.class
new file mode 100644 (file)
index 0000000..9d338d7
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/HQBeamerActivity.class differ
diff --git a/bin/de/bongo/android/hqbeamer/R$attr.class b/bin/de/bongo/android/hqbeamer/R$attr.class
new file mode 100644 (file)
index 0000000..3f0b3a9
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/R$attr.class differ
diff --git a/bin/de/bongo/android/hqbeamer/R$drawable.class b/bin/de/bongo/android/hqbeamer/R$drawable.class
new file mode 100644 (file)
index 0000000..30ff3e9
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/R$drawable.class differ
diff --git a/bin/de/bongo/android/hqbeamer/R$id.class b/bin/de/bongo/android/hqbeamer/R$id.class
new file mode 100644 (file)
index 0000000..61b790a
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/R$id.class differ
diff --git a/bin/de/bongo/android/hqbeamer/R$layout.class b/bin/de/bongo/android/hqbeamer/R$layout.class
new file mode 100644 (file)
index 0000000..6e33ae8
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/R$layout.class differ
diff --git a/bin/de/bongo/android/hqbeamer/R$string.class b/bin/de/bongo/android/hqbeamer/R$string.class
new file mode 100644 (file)
index 0000000..a2e088b
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/R$string.class differ
diff --git a/bin/de/bongo/android/hqbeamer/R.class b/bin/de/bongo/android/hqbeamer/R.class
new file mode 100644 (file)
index 0000000..54db299
Binary files /dev/null and b/bin/de/bongo/android/hqbeamer/R.class differ
diff --git a/bin/resources.ap_ b/bin/resources.ap_
new file mode 100644 (file)
index 0000000..bdbdb97
Binary files /dev/null and b/bin/resources.ap_ differ
diff --git a/default.properties b/default.properties
new file mode 100644 (file)
index 0000000..e2e8061
--- /dev/null
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/gen/de/bongo/android/hqbeamer/R.java b/gen/de/bongo/android/hqbeamer/R.java
new file mode 100644 (file)
index 0000000..614a62b
--- /dev/null
@@ -0,0 +1,27 @@
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package de.bongo.android.hqbeamer;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int icon=0x7f020000;
+    }
+    public static final class id {
+        public static final int powerToggle=0x7f050001;
+        public static final int relativeLayout1=0x7f050000;
+    }
+    public static final class layout {
+        public static final int main=0x7f030000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f040001;
+        public static final int hello=0x7f040000;
+    }
+}
diff --git a/proguard.cfg b/proguard.cfg
new file mode 100644 (file)
index 0000000..b1cdf17
--- /dev/null
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+    native <methods>;
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+   public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+  public static final android.os.Parcelable$Creator *;
+}
diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png
new file mode 100644 (file)
index 0000000..8074c4c
Binary files /dev/null and b/res/drawable-hdpi/icon.png differ
diff --git a/res/drawable-ldpi/icon.png b/res/drawable-ldpi/icon.png
new file mode 100644 (file)
index 0000000..1095584
Binary files /dev/null and b/res/drawable-ldpi/icon.png differ
diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png
new file mode 100644 (file)
index 0000000..a07c69f
Binary files /dev/null and b/res/drawable-mdpi/icon.png differ
diff --git a/res/layout/main.xml b/res/layout/main.xml
new file mode 100644 (file)
index 0000000..f10227c
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
+        <ToggleButton android:layout_height="wrap_content"
+                                 android:text="powerToggle"
+                                 android:layout_width="wrap_content"
+                                 android:id="@+id/powerToggle"
+                                 android:layout_centerVertical="true"
+                                 android:layout_centerHorizontal="true"/>
+    </RelativeLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644 (file)
index 0000000..ee9e1d1
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="hello">Hello World, HQBeamerActivity!</string>
+    <string name="app_name">HQBeamer</string>
+</resources>
diff --git a/src/de/bongo/android/hqbeamer/HQBeamerActivity.java b/src/de/bongo/android/hqbeamer/HQBeamerActivity.java
new file mode 100644 (file)
index 0000000..8115955
--- /dev/null
@@ -0,0 +1,336 @@
+package de.bongo.android.hqbeamer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothSocket;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.widget.CompoundButton;
+import android.widget.Toast;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.ToggleButton;
+
+public class HQBeamerActivity extends Activity {
+    ToggleButton powerToggle = (ToggleButton) findViewById(R.id.powerToggle);
+       private static final int REQUEST_ENABLE_BT = 0;
+       private static final int CHOOSE_DEVICE_DIALOG = 0;
+       private static final int WARN_CHOOSE_DEVICE = 1;
+       private Boolean isBluetoothEnabled = false;
+       private BluetoothAdapter mBluetoothAdapter;
+       private ArrayList<String> availableDevices;
+       private int deviceChosen = 0;
+       private ConnectThread connectThread;
+       private ConnectedThread connectedThread;
+       /* BEGIN Bluetooth / Beamer Messages */
+               /* Begin IDs */
+               private static final int MESSAGE_READ = 0;
+               private static final int MESSAGE_WRITE = 1;
+               /* end IDs */
+       private static final String POWER_ON = "!";
+       private static final String POWER_OFF = Character.toString((char)0x22);
+       /* END Bluetooth / Beamer Messages */
+
+       // Create a BroadcastReceiver for ACTION_FOUND
+    private final BroadcastReceiver 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)) {
+                   // Get the BluetoothDevice object from the Intent
+                   BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+                   // Add the name and address to an array adapter to show in a ListView
+                   availableDevices.add(device.getName() + "\n" + device.getAddress());
+               }
+           }
+       };
+       
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main);
+       
+        /* Start Bluetooth Initialization */
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+               if (mBluetoothAdapter == null) {
+                       this.isBluetoothEnabled = false;
+                       new AlertDialog.Builder(this).setTitle("Error")
+                                          .setMessage("Your device seems not to support Bluetooth :(")
+                                          .setIcon(android.R.drawable.stat_notify_error)
+                                      .setCancelable(false)
+                                      .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                                          public void onClick(DialogInterface dialog, int id) {
+                                                  dialog.dismiss();
+                                          }
+                                      })
+                               .create().show();
+               }
+               else {
+                       if (!mBluetoothAdapter.isEnabled()) {
+                           Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+                           startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+                       }
+                       else {
+                               this.isBluetoothEnabled = true;
+                       }
+               }
+               /* Bluetooth is guaranteed to be avaliable now */
+        
+               /* Prepare blouetooth connection */
+        if (connectThread != null) {connectThread.cancel(); connectThread = null;}
+               while(doBluetoothInquiry());
+                // TODO
+               
+               /* UI Element Setup */
+               this.powerToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+                       public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+
+                       }
+               });
+    }
+    
+    private boolean doBluetoothInquiry() {
+       availableDevices = new ArrayList<String>();
+               ProgressDialog dialog = ProgressDialog.show(this, "", 
+                "Scanning for bluetooth devices...", true);
+               dialog.show();
+               Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
+               // If there are paired devices
+               if (pairedDevices.size() > 0) {
+                   // Loop through paired devices
+                   for (BluetoothDevice device : pairedDevices) {
+                       // Add the name and address to an array adapter to show in a ListView
+                       availableDevices.add(device.getName() + "\n" + device.getAddress());
+                   }
+               }
+               showDialog(CHOOSE_DEVICE_DIALOG);
+               if(deviceChosen == 0){ 
+                       availableDevices.clear();
+                       // user hasn't chosen any of the paired devs, trying to actively scan for some
+                       // Register the BroadcastReceiver
+                       IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
+                       registerReceiver(mReceiver, filter); // Don't forget to unregister during onDestroy
+                       showDialog(CHOOSE_DEVICE_DIALOG);
+                       if(deviceChosen != 0){
+                               return true;
+                       }
+                       else {
+                               showDialog(WARN_CHOOSE_DEVICE);
+                               return false;
+                       }
+               }
+               else {
+                       return true;
+               }
+    } 
+    
+    private class ConnectThread extends Thread {
+        private final BluetoothSocket mmSocket;
+        private final BluetoothDevice mmDevice;
+     
+        public ConnectThread(BluetoothDevice device) {
+            // Use a temporary object that is later assigned to mmSocket,
+            // because mmSocket is final
+            BluetoothSocket tmp = null;
+            mmDevice = device;
+     
+            // Get a BluetoothSocket to connect with the given BluetoothDevice
+            try {
+                // MY_UUID is the app's UUID string, also used by the server code
+               //FIXME may be not avail in later vers better would be API >=10 http://stackoverflow.com/questions/5308373/how-to-create-insecure-rfcomm-socket-in-android
+               Method m = device.getClass().getMethod("createInsecureRfcommSocket", new Class[] {int.class});
+               tmp = (BluetoothSocket) m.invoke(device, 1);
+            } catch (SecurityException e) {
+                               e.printStackTrace();
+                       } catch (NoSuchMethodException e) {
+                               e.printStackTrace();
+                       } catch (IllegalArgumentException e) {
+                               e.printStackTrace();
+                       } catch (IllegalAccessException e) {
+                               e.printStackTrace();
+                       } catch (InvocationTargetException e) {
+                               e.printStackTrace();
+                       }
+            mmSocket = tmp;
+        }
+     
+        public void run() {
+            // Cancel discovery because it will slow down the connection
+            mBluetoothAdapter.cancelDiscovery();
+     
+            try {
+                // Connect the device through the socket. This will block
+                // until it succeeds or throws an exception
+                mmSocket.connect();
+            } catch (IOException connectException) {
+                // Unable to connect; close the socket and get out
+                try {
+                    mmSocket.close();
+                } catch (IOException closeException) { }
+                return;
+            }
+     
+            // Do work to manage the connection (in a separate thread)
+            manageConnectedSocket(mmSocket);
+        }
+     
+        /** Will cancel an in-progress connection, and close the socket */
+        public void cancel() {
+            try {
+                mmSocket.close();
+            } catch (IOException e) { }
+        }
+    }
+    
+    private class ConnectedThread extends Thread {
+        private final BluetoothSocket mmSocket;
+        private final InputStream mmInStream;
+        private final OutputStream mmOutStream;
+     
+        public ConnectedThread(BluetoothSocket socket) {
+            mmSocket = socket;
+            InputStream tmpIn = null;
+            OutputStream tmpOut = null;
+     
+            // Get the input and output streams, using temp objects because
+            // member streams are final
+            try {
+                tmpIn = socket.getInputStream();
+                tmpOut = socket.getOutputStream();
+            } catch (IOException e) { }
+     
+            mmInStream = tmpIn;
+            mmOutStream = tmpOut;
+        }
+     
+        public void run() {
+            byte[] buffer = new byte[1024];  // buffer store for the stream
+            int bytes; // bytes returned from read()
+     
+            // Keep listening to the InputStream until an exception occurs
+            while (true) {
+                try {
+                    // Read from the InputStream
+                    bytes = mmInStream.read(buffer);
+                    // Send the obtained bytes to the UI Activity
+                    mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer)
+                            .sendToTarget();
+                } catch (IOException e) {
+                    break;
+                }
+            }
+        }
+     
+        /* Call this from the main Activity to send data to the remote device */
+        public void write(byte[] bytes) {
+            try {
+                mmOutStream.write(bytes);
+            } catch (IOException e) { }
+        }
+     
+        /* Call this from the main Activity to shutdown the connection */
+        public void cancel() {
+            try {
+                mmSocket.close();
+            } catch (IOException e) { }
+        }
+    }
+    
+    private final Handler mHandler = new Handler() {
+       @Override
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+            case MESSAGE_WRITE:
+                byte[] writeBuf = (byte[]) msg.obj;
+               break;
+            case MESSAGE_READ:
+                byte[] readBuf = (byte[]) msg.obj;
+                // FIXME check if correct code comes back
+                break;
+            }
+        }
+    };
+
+    private void manageConnectedSocket(BluetoothSocket socket){
+       this.connectedThread = new ConnectedThread(socket);
+       connectedThread.start(); // FIXME run()?
+       // FIXME stub
+    }
+    
+protected Dialog onCreateDialog(int id){
+       Dialog dialog;
+       switch(id){
+       case CHOOSE_DEVICE_DIALOG:
+               dialog = new AlertDialog.Builder(HQBeamerActivity.this)
+                                                               .setTitle("Pick a RFCOMM Device")
+                                                               .setItems((String[])availableDevices.toArray(), new DialogInterface.OnClickListener() {
+                                                                   public void onClick(DialogInterface dialog, int item) {
+                                                                       HQBeamerActivity.this.deviceChosen = item;
+                                                                   }
+                                                               }).create();
+               return dialog;
+       case WARN_CHOOSE_DEVICE:
+               dialog = new AlertDialog.Builder(HQBeamerActivity.this)
+                                                               .setTitle("Warning")
+                                                               .setMessage("It's required to choose a device!")
+                                                               .setPositiveButton("Rescan", new DialogInterface.OnClickListener() {
+                                                                               @Override
+                                                                               public void onClick(DialogInterface arg0, int arg1) {
+                                                                                       doBluetoothInquiry();                                                                                   
+                                                                               }
+                                                                       }).create();
+               
+               return dialog;
+       default:
+               return null;
+       }
+    }
+    
+    protected void onActivityResult(int requestCode, int resultCode, Intent data){
+       if(requestCode == REQUEST_ENABLE_BT){
+               if(resultCode != RESULT_OK){
+                       new AlertDialog.Builder(this).setTitle("Error")
+                                  .setMessage("Bluetooth not enabled")
+                                  .setIcon(android.R.drawable.stat_notify_error)
+                              .setCancelable(false)
+                              .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                                  public void onClick(DialogInterface dialog, int id) {
+                                          dialog.dismiss();
+                                  }
+                              })
+                              .setPositiveButton("Retry", new DialogInterface.OnClickListener() {
+                                  public void onClick(DialogInterface dialog, int id) {
+                                                       if (!mBluetoothAdapter.isEnabled()) {
+                                                               HQBeamerActivity.this.isBluetoothEnabled = true;
+                                                               dialog.dismiss();
+                                                       }
+                                  }
+                              }).create().show();
+               }
+       }       
+    }
+    
+    protected void onDestroy(){
+       unregisterReceiver(mReceiver);
+       super.onDestroy();
+    }
+}
\ No newline at end of file