How use Bluetooth GPS modul in app?
-
I'm working on app, which uses GPS data. I have an external bluetooth GPS device, but I can't find how to use the external GPS Bluetooth module. I added the bluetooth permission into my AndroidManifest file, but I dont know how to continue... Please help.
-
Answer:
You should create a connection to the device as described in tutorial Peter http://developer.android.com/guide/topics/wireless/bluetooth.html. Discover devices and present a list to the user to select one. I assume, you have done this and you now have BluetoothDevice device variable set to your device. Connect as client: // This is the default UUID you set for connection - it should work private static final UUID DEFAULT_SPP_UUID = UUID .fromString("00001101-0000-1000-8000-00805F9B34FB"); // .... BluetoothSocket bluetoothSocket = device .createRfcommSocketToServiceRecord(DEFAULT_SPP_UUID); // .... bluetoothSocket.connect(); // Do this when you want to start data retrieval Retrieve information. You can now open an InputStream, from which NMEA messages come in plain text. So you can use BufferedReader for convenience and read messages line by line. Something like this: // After successful connect you can open InputStream InputStream in = bluetoothSocket.getInputStream(); InputStreamReader isr = new InputStreamReader(in); BufferedReader br = new BufferedReader(isr); while (true) { String nmeaMessage = br.readLine(); Log.d("NMEA", nmeaMessage); // parse NMEA messages } // !!!CLOSE Streams!!! REMEMBER: this code is very simplified. In real application every connection to network, device or filesystem resource should be closed when not needed, errors (Exceptions) properly handled and displayed to user in a readable and understandable format.
west44 at Stack Overflow Visit the source
Other answers
Android only supports Bluetooth http://en.wikipedia.org/wiki/Bluetooth_protocols#Radio_frequency_communication_.28RFCOMM.29 (serial emulation) protocol. Make sure your GPS supports this protocol. Then start with the http://developer.android.com/guide/topics/wireless/bluetooth.html.
Peter Knego
Related Q & A:
- How to convert Wordpress to Android app?Best solution by WordPress
- How does a GPS unit work?Best solution by scientificamerican.com
- How do I use my GPS on my Blackberry storm?Best solution by youtube.com
- How can I promote my iPhone app?Best solution by ChaCha
- Do I have to have Yahoo! Mail Plus to use the Android Yahoo! Mail app?Best solution by answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.