Bluetooth Remote on Android to Control Presentations on PC

Being in the networking field for a while i had an interest to develop something on Bluetooth or wi-fi also I have always thought of controlling my laptop from my Android phone, so i targeted Bluetooth.

So here it is "an idea to make my Android phone become a simple remote control for my laptop, just for controlling the Power Point slides for presentation". 


To make it possible i have to go through following challenges:

  1. Remote server on PC 
  2. A way to generate events on remote PC
  3. Remote Controller on Android

For generating events(2) on  PC  u need " java.awt.Robot java.awt.event.InputEvent  " classes .
(Google it for more info)


REMOTE CONTROL SERVER (Java):
     Firstly, we need to write the remote control server to receive the signal from Android phone. I used a Java library for Bluetooth called Bluecove to implement the server. You can download the  bluecove-2.1.0.jar  file and add it to your external library. Note that for Linux, you need to install the bluez-libs to your system and add bluecove-gpl-2.1.0.jar to external library of the project as well (more information  here).
Here is my RemoteBluetoothServer class(read bluetooth-API here):


The main method creates a thread to wait for connection from client and handle the signal.


In waitForConnection() function, firstly it sets up the server by setting the device discoverable, creating the UUID for this application (the client needs this to communicate with server). Then it waits for a connection from a client. When it receives initial connection, it creates ProcessConnectionThread to handle the client’s command. Here is the code for ProcessConnectionThread:


The ProcessConnectionThread mainly waiting for the client’s inputs and process them. This is simple remote control only for going next/previous of Power Point slide so it only process KEY_RIGHT and KEY_LEFT input. I use Robot class from java.awt to generate the key events.
That’s all we need for the Remote Control Server. When you run the server on a computer, make sure that the Bluetooth is ON.


REMOTE CONTROL CLIENT (Android)


    For the client i have followed the guide from Android Dev Guide ....... and yeah u don't need to search anywhere else,tutorial is sufficient.                                                                        
The Screenshot u can see here has  controls :
1. Paired : press it and it will help device retrieve paired devices.
2. Discover : press it and it will discover other bluetooth devices.
3. stop discover: button to stop discovery
4.Arrow button: to control slides movement
5. Start/Stop button: to start/stop sending arrow press signals to sever selected from discovered list.


Well i couldn't find a way to take screenshots off my Android device so i'm showing my Android layout xml.

here are the steps:
Step 1: Enable these permissions 
             <uses-permission android:name="android.permission.BLUETOOTH"/>
            <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
             2nd one needed for discovering devices.

step 2:  We create BluetoothAdapter object and use it enable bluetooth device if it's not enabled.
step 3:  get paired devices  => mbluetoothAdapter.getBondedDevices()
step 4: for discovering new devices we need to register BroadcastReciver object . 
               Every other bluetooth device when activated will generate an intent which can be captured. 
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, filter);
and do mbluetoothAdapter.startDiscovery(); to discover devices.


step 5: use "ItemClickListener" for the Discovered device's list to make the client to connect to that device/server.Before connecting to server stop discovery as it's done  in the code.

step 6: wait for a while for devices to connect and now press the "start" button to start sending signals down to server.

I'm attaching the main_class_file + layout_xml_file.


So here it is a small but effective way to control ur PC over bluetooth..........
This update was a part of developing a "Remote Mouse Control"...looking forward to get it done asap.

Hope this tutorial is fine enough to clear ur doubts and informative too.... :)
-->

Comments

  1. really nice idea!!!
    awesome work...but i strongly suggest you to make an application and give me link so that i can dwnld that application on androd and use it...

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I have shared the server that's meant for PC

      Server: it's a jar file, so just dbl click to run it..make sure bluetooth is on ur PC.

      the ApK: it's the installer for android.
      download it to ur android phone and then click to install there.

      Download Link:
      http://sdrv.ms/NsFhOe


      I will be sharing the source code in a while soon enough

      Delete
    3. one more thing =>wait enough after asking for connection to the server.

      Delete
  2. your application is really good and i need to control the PC mouse in android devices via bluetooth
    if you already done this please send me the source code for bluetooth remote on android to control PC mouse

    ReplyDelete
    Replies
    1. I will share code on github soon

      Delete
    2. dude if u finish the project please send me the link to download (or) send me the code to 409edison@gmail.com ,its very urgent

      Delete
    3. This comment has been removed by the author.

      Delete
    4. find the code here
      https://skydrive.live.com/?cid=4130A7E6BCFA8845&id=4130A7E6BCFA8845%21180

      sorry for the delay .. i couldn't find it anywhere but on skydrive

      Delete
    5. bro this code is used to control the presentation of our PC but i need to control the mouse movement of the PC,please bro i need this code very urgently for my collage project..please bro i need your help...

      Delete
    6. i was working on that .... working on a way where i can send an object/DataStructure containing minimal set of values from android Terminal to the PC ..

      it will take time i don't have a completely working code for it .. was done a year ago.

      Delete
    7. ok dude finish it very soon,because i need this code for my collage project after finish this project send me the code of the apk file and the server code ......

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. download the server and client code for windows/linux and android respectively here find the code here
    https://skydrive.live.com/?cid=4130A7E6BCFA8845&id=4130A7E6BCFA8845%21180

    Android code is bit old you might wanna make a upgrade to newer version of Android SDK

    ReplyDelete
  5. which version of esclipes is used for develop a this android application

    ReplyDelete
    Replies
    1. you can use any eclipse or the one ADT bundle that comes now a days with android sdk..
      better upgrade the android version .

      Delete
  6. please send code for control presentation only

    ReplyDelete
    Replies
    1. you can compare it with the code pasted here at least u can get class name from above and search for it ...

      Delete
  7. dude did u finish mouse control project please send the source code for that project or send me the link to download please i need this project because its my collage project please dude....

    ReplyDelete
  8. Dear When i am running your server side code it is responding-
    Missing Library E:/Server&Eclipse/Android DevelopmentEnvironment/bluecove2.1.1-SNAPSHOT.jar
    and a build path error
    please inform me as soon as u can its urgent
    email-id: abhishek.engineer1305@gmail.com

    ReplyDelete
    Replies
    1. http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.62/
      i think it can help u. let's download these library, add it in your library. If your library was error, delete it and add new library. sr about my EL, not good :))

      Delete
  9. please make sure you have that extra bluecove library(bluez-libs) if you are working on linux environment.
    Although as i was working on this mouse application ... bluecove libs are not responding well on ubuntu.

    ReplyDelete
  10. Hi bro, how to write a code to use Bluetooth remote on android to control PC mouse? Do you have the source code?

    ReplyDelete
  11. Amazing knowledge and I like to share this kind of information with my friends and hope they like it they why I do remote control computer

    ReplyDelete

Post a Comment