Simple Android and Java Bluetooth Application

Last week was my school’s recess week. I had a lot of free time and decided to learn Java and Android Bluetooth by reading the Bluetooth development guide for Android. Then I had an idea to make my Android phone become a simple remote control for my laptop, just for controlling the Power Point slides for presentation. The volume up and volume down become buttons for going to next and previous slide respectively. I write this post to share with you what I have done. I have used Ecipse IDE to write the program.

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:

package com.luugiathuy.apps.remotebluetooth;

public class RemoteBluetoothServer{
	
	public static void main(String[] args) {
		Thread waitThread = new Thread(new WaitThread());
		waitThread.start();
	}
}

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

package com.luugiathuy.apps.remotebluetooth;

import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;

public class WaitThread implements Runnable{

	/** Constructor */
	public WaitThread() {
	}
	
	@Override
	public void run() {
		waitForConnection();		
	}
	
	/** Waiting for connection from devices */
	private void waitForConnection() {
		// retrieve the local Bluetooth device object
		LocalDevice local = null;
		
		StreamConnectionNotifier notifier;
		StreamConnection connection = null;
		
		// setup the server to listen for connection
		try {
			local = LocalDevice.getLocalDevice();
			local.setDiscoverable(DiscoveryAgent.GIAC);
			
			UUID uuid = new UUID(80087355); // "04c6093b-0000-1000-8000-00805f9b34fb"
			String url = "btspp://localhost:" + uuid.toString() + ";name=RemoteBluetooth";
			notifier = (StreamConnectionNotifier)Connector.open(url);
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
       	       	// waiting for connection
		while(true) {
			try {
				System.out.println("waiting for connection...");
	                  	connection = notifier.acceptAndOpen();

				Thread processThread = new Thread(new ProcessConnectionThread(connection));
				processThread.start();
			} catch (Exception e) {
				e.printStackTrace();
				return;
			}
		}
	}
}

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:

package com.luugiathuy.apps.remotebluetooth;

import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.InputStream;

import javax.microedition.io.StreamConnection;

public class ProcessConnectionThread implements Runnable{

	private StreamConnection mConnection;
	
	// Constant that indicate command from devices
	private static final int EXIT_CMD = -1;
	private static final int KEY_RIGHT = 1;
	private static final int KEY_LEFT = 2;
	
	public ProcessConnectionThread(StreamConnection connection)
	{
		mConnection = connection;
	}
	
	@Override
	public void run() {
		try {
			// prepare to receive data
			InputStream inputStream = mConnection.openInputStream();
	        
			System.out.println("waiting for input");

			while (true) {
				int command = inputStream.read();
	        	
				if (command == EXIT_CMD)
				{	
					System.out.println("finish process");
					break;
				}
				processCommand(command);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Process the command from client
	 * @param command the command code
	 */
	private void processCommand(int command) {
		try {
			Robot robot = new Robot();
			switch (command) {
	    		case KEY_RIGHT:
	    			robot.keyPress(KeyEvent.VK_RIGHT);
	    			System.out.println("Right");
	    			break;
	    		case KEY_LEFT:
	    			robot.keyPress(KeyEvent.VK_LEFT);
	    			System.out.println("Left");
	    			break;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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 on Android phone, I have followed the guide from Android Dev Guide and the sample Bluetooth Chat application (You can find this application in the android sdk sample folder).

My program is based on the sample application. The DeviceListActivity class is for scanning devices around to find the remote server and connect to it. The BluetoothCommandService class is for setting up the connection and sending the command to our Remote Control Server. These two files are similar to the sample application. In BluetoothCommandService, I have removed the AcceptThread since the client not need to wait for any connection. The ConnectThread is for initializing the connection with server. The ConnectedThread is for sending the command to server.

The RemoteBluetooth class is our main activity for this application:

protected void onStart() {
	super.onStart();
		
	// If BT is not on, request that it be enabled.
        // setupCommand() will then be called during onActivityResult
	if (!mBluetoothAdapter.isEnabled()) {
		Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
		startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
	}
	// otherwise set up the command service
	else {
		if (mCommandService==null)
			setupCommand();
	}
}

private void setupCommand() {
	// Initialize the BluetoothChatService to perform bluetooth connections
        mCommandService = new BluetoothCommandService(this, mHandler);
}

The onStart() function to check whether the bluetooth on our phone is enabled or not. If not, it creates an Intent to turn the bluetooth on. The setupCommand() to create BluetoothCommandService object to send the command when we push the Volume Up and Down buttons:

public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
		mCommandService.write(BluetoothCommandService.VOL_UP);
		return true;
	}
	else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){
		mCommandService.write(BluetoothCommandService.VOL_DOWN);
		return true;
	}
		
	return super.onKeyDown(keyCode, event);
}

That’s it. Now we can run the server, install the application to the phone and run it :-)

You can go to https://github.com/luugiathuy/Remote-Bluetooth-Android to download the project for client and server.

Update: I developed this application using android sdk 2.1. And as comments below, the application is not working with Android SDK 3.x. I don’t have Android tablet to test it yet. Sorry about that.

FacebookLinkedInDiggBlogger PostStumbleUponPingEmailShare

199 Comments

Filed under Android, Java

199 Responses to Simple Android and Java Bluetooth Application

  1. damiannelus

    As almoast everyone before, let me thank for such a great job.
    I have some troubles with connecting.

    I turn BT on both on PC and Android device.
    Devices are paired.
    Server is started with “waiting for connection…”
    I start client, establishing connection (with “connected: [PC_NAME]“).
    and that’s all. I assume, i should get “waiting for input” message, but nothing happend.

    Have you any solution or idea what’s wrong?

    Best wishes,
    Damian

  2. Diego

    Hey this works great! nice job!

    I have an issue, though. When I change screen orientation on the android client, the connection gets lost. It’s strange since it doesn’t happen with the BluetoothChat sample. Does anyone know how to solve this?

  3. androcon

    can u help me out in doing this using Wi-Fi??? plz help

  4. mike

    Hi,

    looks great! I have an application where the android is the host and remote hardware connects to it. Do I just use the accept thread and ignore the connect thread?

    I new to android!

    thanks in advance,

    mike

  5. taher

    hi i am working on bluetooth based project. i want to transmit integer data of seekbar progress value. but i am getting garbage value. please help me out

  6. Behzad

    Hi,
    Thanks man, you are great. It helps me a lot.

  7. kader

    Hi Gia,

    Really it’s a nice pg!
    I am geting an exception in compiling the server. any help would be grateful.

    kader
    —————
    Native Library intelbth_x64 not available
    Native Library bluecove_x64 not available
    Bluetooth is not turned on.
    javax.bluetooth.BluetoothStateException: BlueCove libraries not available
    at com.intel.bluetooth.BlueCoveImpl.createDetectorOnWindows(BlueCoveImpl.java:896)
    at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:439)
    at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
    at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1020)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1018)
    at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1011)
    at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
    at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
    at com.example.chapter7_remotebluetooth.WaitThread.waitForConnection(WaitThread.java:34)
    at com.example.chapter7_remotebluetooth.WaitThread.run(WaitThread.java:21)
    at java.lang.Thread.run(Unknown Source)
    ———-

    • Hi Kader,

      You should run the program on jre 32bit. It’s because the bluecove library does not support 64bit yet. Hope it helps!

      • Luciano

        Hi Gia really nice but I have the same exception and I’m working with jre-7u7-windows-i586 32 bits?
        I don’t know what I’m doing wrong

        • Luciano

          This is what i get
          javax.bluetooth.BluetoothStateException: BlueCove native library version mismatch
          at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:454)
          at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
          at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1020)
          at java.security.AccessController.doPrivileged(Native Method)
          at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1018)
          at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1011)
          at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
          at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
          at appbluetooth.WaitThread.waitForConnection(WaitThread.java:36)
          at appbluetooth.WaitThread.run(WaitThread.java:23)
          at java.lang.Thread.run(Thread.java:722)

  8. muaz

    Hi. I got the app working on Samsung Galaxy Tab 7.0
    It can connect to the laptop, but the server on the laptop does not respond, showing “waiting for connections…”

    Is the server aware the laptop is being connected :/
    Tried putting breakpoints and found that the server stuck at
    connection = notifier.acceptAndOpen();

    Its waiting forever

  9. sam

    hi,
    I want to communicate 2 android device. i have android cell phone and android tablet how i can access tablet using my cell phone,
    Scenario i want to open browser in tablet by passing command from cell phone.

    Thanks,
    Sam

  10. Adam

    Hi Gia.
    Your program rlz man:) Nice work.

    Could you help me anyway? I am student from Poland at Automatics and Robotics. I write my app in Java as a diploma and have some problems in it. If you have some time please e-mail me:
    AdamPL90@wp.pl

    Once again – good job:) Be proud of it.

  11. Abdul Matin Muaj

    Really this is a great project.I have successfully run it.I have made exe file of desktop remoteserver but when I run it doesn’t help to connect android with my laptop.It only works why I run it by Netbeans IDE please anyone help me…………

    • Abdul Matin Muaj

      Corr: It only works when I run remoteserver by NetBeans IDE .How can I run it without IDE ?

      • Marcelo Luz

        Try to export your project as a JAR file then run it with a command line like: java -jar yourapp.jar

        • Abdul Matin Muaj

          I have made jar file of this application .I can run jar file of desktop application.Jar file of this application can be executed but immediately terminate and doesn’t recieve any command from my android.Is there any solution ?

  12. nonozor

    Hi !!
    Great job !
    I could make it working for android <=2.1 >=3.0
    But how can I make it works with android >2.1 and <3.0 for example for android 2.3.3 (with my Galaxy S) ??

    Thanks !
    Arno.

    • nonozor

      Finnaly I found the answer here :
      http://stackoverflow.com/questions/10315376/remote-bluetooth

      I’m very glad because I was blocking since a lot of time with this problem !

      • hessi

        Hi all… I have a problem with HTC
        this code is running on Samsong’s Android 2.3.6 easily and works very nice!,
        but it is not compatible with HTC’s Android 2.2.1… prompts the “unable to connect device” message, when i try to connect.
        i read stackoverflow but can not solve my problem.
        i was programming in netbeans with Android sdk 4.0.3
        can anyone help me ? should i change uuid ?? how ?
        thanks a lot.

      • Luciano

        can you sen me your .apk for andorid 2.3 please? luciano_crux@hot

  13. Darlan

    Hello, As you used the java.awt with android and there is no possibility to use with android. I found some people with the same problem.

  14. folp

    Hi Gia,
    Congratulations to your job!!
    Is there any restriction of the version of the android development for Bluetooth? In developer.android site indicates that it is for versions from the 11 level. Is that right?
    Thanks

  15. thai_tam_2406

    Hi Gia Thuy.
    Toi co 1 cau hoi la thu vien Bluecove có ho tro dieu khien chuot tren laptop hay khong.Neu khong thi minh phai lam the nao de lam duoc dieu do.
    Cam on ban rat nhieu.
    Mong nhan duoc su tro giup cua ban trong thoi gian som nhat!

  16. srk

    Actually i’m getting the following while executing the server code

    BlueCove version 2.1.0 on winsock
    0000110100001000800000805f9b34fb
    waiting for connection…

    how to give input via android phone …

  17. DO-IT

    hi all !
    Thank for your app
    But you can help me. I have a problem :connection = notifier.acceptAndOpen(); is not running
    I tried Leslie ‘s solution but it is not effective.
    Please ! help me
    Thanks so much

  18. Tom

    Great work good sir, you will go far in your career!

  19. Rahul Kundu

    Hi Gia
    Thank you for this nice program.
    I am facing same problem as abdo. If you got any solution please help me.
    Thanks and regards
    Rahul

    Error Details

    Exception in thread “Thread-0? java.lang.UnsatisfiedLinkError: com.intel.bluetooth.BluetoothStackToshiba.getLibraryVersion()I
    at com.intel.bluetooth.BluetoothStackToshiba.getLibraryVersion(Native Method)
    at com.intel.bluetooth.BlueCoveImpl.setBluetoothStack(BlueCoveImpl.java:939)
    at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:482)
    at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
    at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1020)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1018)
    at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1011)
    at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
    at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
    at com.luugiathuy.apps.remotebluetooth.WaitThread.waitForConnection(WaitThread.java:31)
    at com.luugiathuy.apps.remotebluetooth.WaitThread.run(WaitThread.java:18)
    at java.lang.Thread.run(Unknown Source)

    • Rahul Kundu

      Hi Gia
      Problem that I mentioned in previous post has been solved. Toshiba bluetooth stack is not compatible with bluecove. So I have purchased one external bluetooth device. Now the server is working fine.
      But the mobile side is failed to discover the remote device. I am working on it. If you have any specific trick please share with us.
      Once again Thanks for the nice programme.

  20. Rajat

    Hello ,
    I can make both the codes (the client and server side) wunning successfully. but i Want to send data from my laptop and receive it on my phone .
    Can someone guide me how to do this ?
    Thanks ..

    • alex

      Hi Rajat. I was wondering if ur using a 32 or 64 bits system. cause I get native errors on 64 system. and there were supposed to be some snapshopt for 64 bits but all links are dead. If ur on 64bit too can you please let me know how you managed to get the pc server side up and running.

      Thanks,
      alex

  21. Gursheen

    Hi Gia.. this is Gursheen from India, first of all great job buddy. its a very nice application. i need you help urgently. Currently i tested your sample code. my phone got connected with the server but no keypad was displayed on phone to operate my laptop. Im using smartphone with touch screen which has android 2.3 version. can u plz suggest me with something. need it urgently.

    • KZ

      Hi Gursheen,
      the sample have not UI implmented on it. you can control your laptop via VOLUME_UP and VOLUME_DOWN.

      • Gursheen

        Hey
        thanx for the reply. i know the above code is only for VOLUME_UP and VOLUME_DOWN but i need code for touch screen. if you could assist me to it i would be grateful to u.

  22. Utsav

    Hey.. great project !!!

    m planning on making a bluetooth tag kind of something …which is to b controlled by a smartphone….after pairing it up with a application which is to b developed on the smartphone….if the tag is taken apart say about more than 5m from the phone….it should trigger a alarm on the phone……can u plzzz guide me on that … wat bluetooth module to b used and how can i pair it up with an android app….plzz guide !!!

  23. vijay

    private final BluetoothSocket mmSocket;
    private final BluetoothDevice mmDevice;

    public ConnectThread(BluetoothDevice device)
    {
    mmDevice = device;
    BluetoothSocket tmp = null;
    Method m = null;

    try {
    //now able to connected to device ……… ////…
    m = mmDevice.getClass().getMethod(“createRfcommSocket”,
    new Class[] { int.class });

    } catch (Exception e)
    {

    System.out.println(“The Error in found….”);

    }

    try {

    tmp = (BluetoothSocket) m.invoke(mmDevice, 1);

    } catch (Exception e)
    {
    // TODO: handle exception.
    System.out.println(“The Error in found….”);

    }

    mmSocket = tmp;
    }
    i use this code for connection it working … vijay

  24. vijay

    code is not working ,, unable to connected any one know the idea about

  25. teddy

    Hi,
    It’s me again. after much googling, I managed to connect to the PC. the only changes i made is by changing the uuid to 00001101-0000-1000-8000-00805F9B34FB for both server and client side and it works.

    But new problem occurs, after the phone is connected, the application stop unexpectedly. Since AVD does not support bluetooth, can you guide me on how to debug and pinpoint where might be the error?

    thanks

    • hessi

      you must use this format in server (laptop) :
      “0000110100001000800000805F9B34FB” without any dash
      and a format for client (mobile) likes this :
      “00001101-0000-1000-8000-00805F9B34FB”
      unless you encounter a message likes unfortunately your program stop

  26. Dim itar

    Very good! Thank you!

  27. Gaurav

    Hello! I am a 3rd year student from Pune and i am working on a project related to Bluetooth.
    Actually, we have created a BOT with wheels and we want to run that bot from our android phone.
    I just had some doubts regarding the sending of bluetooth signals(as to which type of commands) to the controller.
    We have 4 buttons viz Forward,Reverse,Left,Right.
    How do i send any signal with the pressing of these buttons ?? Please Help!
    Thnx in advance! :)

  28. swathi

    hi …
    I am a 3rd year BE student from Information science branch, presently i m working on an application on video streaming via bluetooth for the android platform. Basically my aim to play the same video simultaneously in two android phones via bluetooth(this doesnt involves real time streaming). I tried the basic bluetooth chat code from developer site to establish the connectivity, but i could’nt make it .i m done till the pairing .Can you please help me regarding this .If you have any idea on video streaming via bluetooth ,then please let me know.
    thank you in advance…,

  29. Miguel

    Hi all,

    First of all thank’s for the code, is great!
    I have a problem, when I try to connect my mobile device a Toast appears saying “unable to connect device” Can someone help me?

    Thanks a lot.

  30. Shivika

    Hi Gia,
    I am very thankful that you shared the code.But there is a problem the code is working only till
    BlueCove 2.0.1 version
    wating for connection….
    plzz tell me how to proceed after this.

    thanks a ton (in advance) :)

    • Hi Shivika,
      That is the server program. It’s waiting for connection from a phone. You need to run the app on your android phone and pair the bluetooth with your laptop. Then you can use your phone to remote the laptop as I’ve explained above. Hope it helps!

      • shivika

        Thanks Gia for quick reply but the problem is I have a problem, when I try to connect my mobile device a Toast appears saying “unable to connect device” .
        plzz help me with this

        • Hi Shivika, Can I make sure that you connect to correct laptop which runs the remote bluetooth server program? Your laptop’s bluetooth need to be discoverable so that the phone can search and connect to.

          • teddy

            strange, i also have the same problem with shivika here, i managed to compile the apk and jar file, and run the server,it says waiting for connection, but then when i try to connect with the phone, it say unable to connect to device. i already make the laptop to be discoverable though, any idea? or log where i can look into?

  31. kishore

    thanks for the quick reply , i have implemented code in netbeans . It is sending file to NOKIA phones but for android phones it says “selected device is down”. please help me, or tell me how to modify this code suitable to my project. Thanks a million in advance.

  32. kishore

    I want send a file from server PC to android phone via bluetooth , please help me it is my final year projrct . I am even ready to pay money if you want.

    • Hi! May I know what problems you’ve encountered so I can help?
      The idea is similar to this app. You send byte data of the file from your PC to the phone.

      • kishore

        I have used OBEX protocol for send file.

      • kishore

        Hi , i am doing engg in BMS College Of Engg Bangalore. I am currently in final year (computer science branch), i am doing a project called “restricting android mobile phone features inside college campus(ie blocking multimedia features) “, for that i have to send application to android mobile using bluetooth when mobile is inside campus . I know it can be done using OBEX protocol and i am able to send files to NOKIA phones but android phones are not receiving , please help me in sending application to mobile phone using bluetooth or even other suitable means for this project , i am ready pay money for that . Please help me , i am stuck with my project.

      • kishore

        sorry i sent many msgs , thanks for quick reply i have implemented code in netbeans , i am able to send file to NOKIA phones but for android phones it gives an exception saying “selected device is down” . suggest me how i can modify your code to work for my project , plz and thanks in advance.

  33. Avseq

    Hi, i am a beginner in Android development. I just successfully implemented this app. thanx a lot for that. But i want to ask one question.
    How can i add swipe gestures to control the slides in the app?

    please help….

  34. Alice

    Hello,
    I just wanted to ask why the device connection is lost when we press back button or home button. Would running the whole app as a service solve the problem? How else can we solve this?
    Thanks you very much.

  35. Marco

    Hi,
    I´m from Brazil and found your site on google.
    I implemented your Server code in my Android aplication, but it didn´t work,
    something about the bluecove… You didn´t design the Server to be running in a
    mobile right?
    How can I adapt this to make it work?
    Can you help?

    Please reach me by email, ok?

    • Hi Marco, Yes I’ve implemented the Server to be run on PC, not mobile device. If you want a server on an Android phone, you can look up the Bluetooth Chat Example on Android Development. Hope this helps!

  36. akki

    Helllo everyone
    rushabh,thuy,aparna,prajakta

    tHANX alot………….M trying to implement “Remote Desktop Access on Mobile via bluetooth”,
    ie. We can control our pc on android phone
    and has very little time left to finish it of…

    Right now i am still struggling with the “Bluetooth Connection Setup”
    especially because of the (1)”ForceCLOSE ERROR”,I have included Exceptions Which never pops up
    (2)I am unable to test my app on laptop every time I use mobile to test.

    (3)As of now there is some problem At the mmsocket.connect() function call on android code.

    (10)now when i try to execute this CODE given here……It gives error “Unable to Connect”

    Any ideas, Help, Links, blessings :p are welcomed………
    PLz do share your views and

    Thanks and Regards
    Akshay Mane
    a k s h a y 4 4 9 7 m a n e @ g m a i l . c o m

    plzzzzzzz Help………

  37. Akki

    thanx buddy……………thts for remote work

  38. Kieth Boyd

    I was wondering if anybody solve their problems with bluetooth? I working this app that keep score bluetooth.
    thanks

  39. Rushabh Patel

    hi,
    i have used this application to make one bar code scanner in android which scans the code and send the bar code directly to the desktop JAVA application Bluetooth server Via Bluetooth.
    but when i run both application then its connected fine but when i send bar code on button click its not sends the MSG to desktop but yes if i minimize the android application desktop server receives that code instantly.
    It seems funny but that is problem and i can not figured out this yet. So if you have any solution or idea then please tell me.

  40. Hi,
    Can any one please give me the Zip file of the project (Both Client and Server)
    Thanks in advance.

    -Rahi.

  41. Aparna

    hi i’m beginner in android even java too i have neared my dead line to submit a android project regarding bluetooth i tried o implement yours but i get parser on running the apk in my mobile can u send me a working model or could you explain me the code i request for possible reply as soon a possible. while implementing the server stays at waiting for connection but on running the apk i get parser error. so i tried manual pairing but the server stays at same position :( it will be very grateful if you send a positive reply as soon as possible

  42. gani

    i want a sample program for building a app which should send predefined character using bluetooth
    when a butten is pressed in android phone… thanking u…

  43. mohamed

    thank you very much for this app
    but i need some help the app is connecting but it when attemp to close it in
    mobile the mobile go hang and i try it more and more but without any work

    please help and thank you for advance

  44. Prajakta

    Hi Gia,

    I tried to run this application. Initially I was also facing the same problem; android app was showing a message “unable to connect”, when i was trying to connect it with java app on my laptop.

    I found the solution on : http://stackoverflow.com/questions/5615186/trouble-coneccting-pc-with-android-2-1-mobile-for-the-bluetooth-chat-example
    and now it is able to connect. But now I am facing a new problem… even if android app is connecting to laptop bluetooth, java app is not responding at all.
    in waitThread.java , app is running without any problem till connection = notifier.acceptAndOpen();
    but once bluetooth connection happens, its not hitting any breakpoint at all.
    Can you help me out?

    Thanks in advance :)

  45. Prajakta

    Hi Gia,

    I tried to run this application. Initially I was also facing the same problem; android app was showing a message “unable to connect”, when i was trying to connect it with java app on my laptop.

    I found the solution on : http://stackoverflow.com/questions/5615186/trouble-coneccting-pc-with-android-2-1-mobile-for-the-bluetooth-chat-example
    and now it is able to connect. But now I am facing a new problem… even if android app is connecting to laptop bluetooth, java app is not responding at all.
    in waitThread.java , app is running without any problem till connection = notifier.acceptAndOpen();
    but once bluetooth connection happens, its not hitting any breakpoint at all.
    Can you help me out??

    Thanks in advance :)

  46. abdo serag

    Hi
    Thanks for the magnificent program, i tried to implement it, but caught some errors !!
    Help me plz ASP.
    and that is a pic of my errors
    http://www.mediafire.com/imageview.php?quickkey=tgwmhg8ok5m3yw8
    thanks in advance
    Exception in thread “Thread-0″ java.lang.UnsatisfiedLinkError: com.intel.bluetooth.BluetoothStackToshiba.getLibraryVersion()I
    at com.intel.bluetooth.BluetoothStackToshiba.getLibraryVersion(Native Method)
    at com.intel.bluetooth.BlueCoveImpl.setBluetoothStack(BlueCoveImpl.java:939)
    at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:482)
    at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
    at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1020)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1018)
    at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1011)
    at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
    at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
    at com.luugiathuy.apps.remotebluetooth.WaitThread.waitForConnection(WaitThread.java:31)
    at com.luugiathuy.apps.remotebluetooth.WaitThread.run(WaitThread.java:18)
    at java.lang.Thread.run(Unknown Source)

    • Rahul Kundu

      Hi Gia
      I am facing same problem as abdo. If you got any solution please help me.
      Thanks and regards
      Rahul

      Error Details

      Exception in thread “Thread-0″ java.lang.UnsatisfiedLinkError: com.intel.bluetooth.BluetoothStackToshiba.getLibraryVersion()I
      at com.intel.bluetooth.BluetoothStackToshiba.getLibraryVersion(Native Method)
      at com.intel.bluetooth.BlueCoveImpl.setBluetoothStack(BlueCoveImpl.java:939)
      at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:482)
      at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
      at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1020)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1018)
      at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1011)
      at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
      at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
      at com.luugiathuy.apps.remotebluetooth.WaitThread.waitForConnection(WaitThread.java:31)
      at com.luugiathuy.apps.remotebluetooth.WaitThread.run(WaitThread.java:18)
      at java.lang.Thread.run(Unknown Source)

  47. JR Gapuz

    I have this GPS application.. i want to trigger the gps application with the help of the data received via bluetooth.. is there any that the received txt file or signal could be able to trigger the gps/location manager in the android application? any links that would help me on developing this application?

  48. Leslie

    Hey Gia… amazing program… made it as simple as possible and as effective… thnx a million :-)
    I am currently working on a project to create an android app as a mousepad and keyboard for any laptop or pc with docks for module additions such as volume controls, shut down options, etc which can be added by any interested andro nerd…
    I have finished the design, but am stuck at the back-end… can u pl help me conceptually by telling me how i can implement your project over wifi rather than bluetooth…?? It would really help me a lot… Thnx again man… Tc

    • Leslie

      Hey… i figured it out… change the UUID address in the BluetoothCommandService.java in the client side andro app and the Wait thread() in the server jar side…

      Make sure that the UUID in the client side is of the form 00001101-0000-1000-8000-00805F9B34FB and in the server is 0000110100001000800000805F9B34FB … just replace the existing UUID’s with the one I have mentioned here… pl let me know if this has worked, cos it worked for me… All the best amigos :-)

      Ps. Thnx a million for the initiating code and inspiration Gia… Tc

      • akki

        Hiiiie
        congrats for u figuring out solution.

        M sure u can help me………..thnx in advance

        basically………….M trying to implement “Remote Desktop Access on Mobile via bluetooth”,
        ie. We can control our pc on android phone
        and has very little time left to finish it of…

        Right now i am still struggling with the “Bluetooth Connection Setup”
        especially because of the (1)”ForceCLOSE ERROR”,I have included Exceptions Which never pops up
        (2)I am unable to test my app on laptop every time I use mobile to test.

        (3)As of now there is some problem At the mmsocket.connect() function call on android code.

        (10)now when i try to execute this CODE given here……It gives error “Unable to Connect”

        Any ideas, Help, Links, blessings :p are welcomed………
        PLz do share your views and

        Thanks and Regards
        Akshay Mane
        a k s h a y 4 4 9 7 m a n e @ g m a i l . c o m

        plzzzzzzz take ur time n Help me………

        • Sai

          Hi Akki,
          As far as I can see its “unable to connect” due to the fact that android emulator doesnt support bluetooth. I am sure you are aware of this; still a reminder. Hope it helps.

      • dude

        Hi Leslie,
        I managed to get the regular Bluetooth example working thanks to Gia!

        I am trying to understand what is the difference of your example above? Can you please explain what is the difference ?Thanks!

    • Thanks for your solution Leslie =)

    • thai_tam_2406

      Hi Leslie.
      You can share project android app as a mousepad and keyboard.I very need this project.
      Thanks you very much.

  49. Pop Ioan Mihai

    Hi,
    Nice tutorials, but i have a little question. I`ve tried your example from https://github.com/luugiathuy/Remote-Bluetooth-Android client example and when i try to write somethig(after succefully i am connected to the remote device), I get Connection reset by peer.
    Thanks.

Leave a Reply