Bluetooth socket close function problem - Android Software Development

Hi, first sorry for my english
I have a question, I'm writting bluetooth app where I need to use close function for bluetooth socket becouse when I'm connected with other device I need to change the connected device to other. My problem is: when I click on other device to connect my app closes mediately.
I use try {} catch function for bluetoothsocket.close();
this problem is only where I'm connected to other device, I think the problem is in bluetooth socket closing function becouse when that function starts my app kills.
How to resolve this problem?
I use ported Froyo on Kaiser

Related

Any software which can be used to auto pair bluetooth device with WM6?

I have annoying problem with my GPS receiver GBGPS201.
Every time I switch it off, next time I switch it on I have to establish new pair with my WM6 even though in Bluetooth manager is shows device as discovered (I use BT headset and it works without any problems).
I called vendor and they told me that GBGPS201 GPS device does not support "auto pairing".
So each time I want to use a device, I have to pair it, choose "serial port", create new outgoing serial port and only after that be able to use navigation software.
My question is wether there is some utility there which will do it for me?
G

CarKitMode mode activator (CU-S400 Emulator)

Hi,
I've installed the update for Navipanel hoping it would work now, even though I don't have the CU-S400. I start the Navipanel.exe from the exe in the Windows folder, and it starts up as expected. When I try to make a call the dialer always switches to portrait even though Navipanel is in landscape.
Could this be a dialer problem (I have the latest Energy ROM) or is it because I started navipanel by hand.
Anyone knows how to solve this? Is there a registry key that forces the dialer to stay in landscape mode? Or is there something I can do with the microusb power connector (short pins?) to force the landscape mode?
It would be great if anyone is able to give me some details on registry changes when the CU-S400 connects (can be detected using SKTracker) so I can maybe write a utility/tool force this mode without the actual carkit.
Any help is apreciated, I hate it when the device return to portrait while I'm driving.
Thanks in advance.
Edit: Nothing was available so I cooked up something myself. See post 31 for a cab file.
le_cactus said:
Hi,
I've installed the update for Navipanel hoping it would work now, even though I don't have the CU-S400. I start the Navipanel.exe from the exe in the Windows folder, and it starts up as expected. When I try to make a call the dialer always switches to portrait even though Navipanel is in landscape.
Could this be a dialer problem (I have the latest Energy ROM) or is it because I started navipanel by hand.
Anyone knows how to solve this? Is there a registry key that forces the dialer to stay in landscape mode? Or is there something I can do with the microusb power connector (short pins?) to force the landscape mode?
It would be great if anyone is able to give me some details on registry changes when the CU-S400 connects (can be detected using SKTracker) so I can maybe write a utility/tool force this mode without the actual carkit.
Any help is apreciated, I hate it when the device return to portrait while I'm driving.
Thanks in advance.
Click to expand...
Click to collapse
Its more of a quick work-around rather than a total fix, but have you tried Gyrator2? Its a program that allows the screen to rotate in pretty much all programs.
Hi,
I did, but it doesnt work; the dialer goes to portrait mode, and only switches to landscape again if I hold my phone in portrait and then to landscape again.
Is there noboby who has got it working and is willing to check somethings?
TIA,
Cheers,
/Cacti
I have htc car holder CU-S400 and for me it stays in the landscape even in dialer mode.
I have tried to start navipanel without car holder but then in dialer mode it goes to portrait.
I belive it is related to micro usb on car holder.I hope this will help.
It does, thanks. I've send you a PM.
Cheers,
/Cacti
I'm in Jakarta - Indonesia.
My car kit CU S400 has arrived yesterday, in navi panel mode can we use another program beside co pilot for navigation, how to choose or change the default (co pilot).
I've ask to support center and it's been 36 hours and still no answer to my question.
hope someone can help me.
regards,
Raymond Widya
Pinout?
chavonbravo said:
Well, it seems the registry that enables/disables NaviPanel is in HKLM\System\CurrentControlSet\Keypad\"IsCarKitMode" with dword 0 or 1. The file that controls this registry settings going on or off is HTCApplication.dll. The 'Keypad' key doesn't exist, so you'll have to add it and add the IsCarKitMode dword value.
I can't get it to work with my a2dp stereo headphones to connect automatically, but I think this is because when doing the bluetooth handshake, some flags must not be set that show it to be a car kit possibly. Only other option would be bthutil.dll after that and see what it does.
Click to expand...
Click to collapse
So, digging in some more I found this post. The IsCarKitMode registry key does exist on our HD2's, and changing it's value to 1 briefly brings up the Navipanel. But sometings ( I guess the HTC Application service) changes it rights back to 0, disableing the 'true' landscape mode. Disableing the service isn't an option I think; it handles much more then just the car kit mode. An looking at the DLL that handles the service (HTCApplication.dll) didn't give me much info; the IsCarKitMode strings didn't even exist in it.
So now I'm looking for the pinout of the CU-S400 micro USB connector. I know the three coper connections beside the SIM may have the answer, but I also found threads stating certain Mini2Micro USB adapters made the device think it's in car kit mode. Anyone with any input on how to hardwire this please speakup
TIA,
Cheers,
Cacti
Never mind, I got it working now
Thanks for all your help
I've got a working NaviPanel and landscape dialer even withou the CU-S400. It detects AC power, waits for my BT Carkit to connect and then starts NaviPanel. True landscape, even if the dialer is started and when a call comes in.
Now all I need to figure out why every navigation shortcut in NaviPanel adds the Show parameter to CoPilot, and how CoPilot knows need to Go Home, Show Recent places, Addresses of simply start.
Again, I need the help. this time from someone using CoPilot and who is willing to use SKTracker to find out what's going on. I almost have the perfect solution, I'm nearly there
TIA,
Cheers,
/Cacti
le_cactus said:
Thanks for all your help
I've got a working NaviPanel and landscape dialer even withou the CU-S400. It detects AC power, waits for my BT Carkit to connect and then starts NaviPanel. True landscape, even if the dialer is started and when a call comes in.
Click to expand...
Click to collapse
Would you like to share your setup ?
Go on le_cactus,and I am glad to see that you found solution for your problem.
I am sorry for didn't send you requested screenshot,but I was on trip and I didn't have good internet connection.
I hope you will find solution how to integrate alternative navigation system with navipanel,and I hope one of them will be GarminXT.
You know I really hate when someone says "I found a solution" and does not care enough to share the solution with others, but yet had to ask here in the first place. As for the navipanel, if you connect pin 4 to ground it will start up navipanel and let you use the dialer in landscape without it rotating to portrait first. Hope this helps others finding their way here for a solution.
duplicate sorry!
iBlade67 said:
You know I really hate when someone says "I found a solution" and does not care enough to share the solution with others, but yet had to ask here in the first place. As for the navipanel, if you connect pin 4 to ground it will start up navipanel and let you use the dialer in landscape without it rotating to portrait first. Hope this helps others finding their way here for a solution.
Click to expand...
Click to collapse
Yes that was Bl**dy annoying.
However here is the answer.
It is possible to modify any car power adapter to enable navipanel. You must indeed connect pin 4 to ground pin 5. However I have discovered it is not that simple, that did not work on my power adapter. The reason was this.
Most power adapters connect pins 2+3 (the USB data lines) together to identify that it is a charger capable of supplying higher power than a PC USB port. This enables "fast charge". with these pins connected the HD2 wont go into navipanel.
It is neccessary to remove the link between pins 2+3 and instead link 4+5.
This allows the HD2 to switch to navipanel mode and at the same time recognise there is a high power charger present!!
The pins look like this from the rear
* * *
* *
numbered
5 3 1
4 2
I hope this helps someone else looking for this solution. It would be great if you could buy a "proper" aftermarket car adapter for the HD2 that had this mod done!
Cheers all and enjoy!
bob_bournemouth said:
Yes that was Bl**dy annoying.
However here is the answer.
It is possible to modify any car power adapter to enable navipanel. You must indeed connect pin 4 to ground pin 5. However I have discovered it is not that simple, that did not work on my power adapter. The reason was this.
Most power adapters connect pins 2+3 (the USB data lines) together to identify that it is a charger capable of supplying higher power than a PC USB port. This enables "fast charge". with these pins connected the HD2 wont go into navipanel.
It is neccessary to remove the link between pins 2+3 and instead link 4+5.
This allows the HD2 to switch to navipanel mode and at the same time recognise there is a high power charger present!!
The pins look like this from the rear
* * *
* *
numbered
5 3 1
4 2
I hope this helps someone else looking for this solution. It would be great if you could buy a "proper" aftermarket car adapter for the HD2 that had this mod done!
Cheers all and enjoy!
Click to expand...
Click to collapse
Hi Bob,
I was also annoyed ybout the missing possibility to start the car kit mode. The Navi Panel was not a problem to start with a shortcut but unfortunately the predefined connect to my Parrot hands free set via bluetooth wouldnt work. So I have to crack it on the hardware side
I was very happy about your posting and the provided solution. I plan to start a field trial with a micro USB cable, my side cutter and my soldering iron. Hopefully I can affirm your pin-bridges
But before I start, I have to be sure that I count the plug pins right. Is the numbering of attached picture right or should I have to count otherwise?
Thanks for your help.
Here I got the answer!
http://translate.google.at/translat....cz/forum/viewtopic.php?f=3&t=73&p=1037#p1037
original usb adaptor solved this issue
I am coming from tytn II and I have the original htc car charger, when I purchased the HD2 I found that the charger can't be used with it, then I went back to HTC store here in Saudi Arabia and asked for an adaptor (USB mini to USB micro), and it cost less than 3 USD and once I attached to the HD2 it went to the Navipanal.
I think the solution of the resistor was built in it or it is because of using the original HTC car charger (which was for the Tytn II).
Funny thing that I thought that this is natural with any Car charger till I saw this thread
CU-S400 Emulator
Hi,
I finaly got a working CU-S400 Car Holder emulator! When using my HD2 in landscape mode in my car I ran into the following problems:
The device changes to portrait mode everytime the dialer comes up
The device always goes to speakerphone on incoming calls, even though my Parrot carkit is connected. Outgoing call are routed through my Parrot carkit though. I always had to manualy disable speakerphone on every incomming call.
I have to switch on Bluetooth everytime I enter my car; having BT on all the time drains my battery to fast
Running NaviPanel (to solve part of the above problems) disables the StartMenu hardkey, and changes the Home hardkey to always change to NaviPanel instead of Sense.
The attached ZIP file contains the following files:
CarKitMode Detect Helper.exe - A modified file that is originaly used by the Via Michelin GSP software. It detects if AC Power is connected of disconnected, and the launches my HTC_car_kit_mode_auto.exe. It either launches with the AC_ON or AC_OFF parameter, depending on wheter AC is connected or disconnected.
CarKitMode Detect Helper.lnk - The shortcut that is placed in \Windows\StartUp to autostart the monitoring of te AC connection.
HTC_car_kit_mode_auto.exe - A Basic4PPC file I created. If started with the AC_ON parameter it changes the registry so my HD2 thinks it's connected to a CU-S400 Car Holder. It enables Blueooth and then waits for 2 minutes to see i the bluetooth device specified in NaviPanel settings is connected. If not, shuts itself down after disabling Bluetooth. If Bluetooth is connected sits, and waits for a call, and then disables speakerphone if it sees that speakerphone is enabled. That way the call is routed through the BT device.
When started with the AC_OFF parameter it changes the registry back, disables BT and shuts itself down.
VJSpeakerPhoneOFF.exe - The program that is called to disable speakerphone. It's part of the VJPhoneShortcuts suite that was created many years back by Vijay555. Big thanks to him, although I'm sure there are other programs that will do the same.
I've tested a lot, and can't find any battery or performance penalty for the always running helper application. And the HTC_car_kit_mode_auto only runs if AC power is connected, and then only for two minutes if the BT device isn't connected. Just unzip the attached CU-S400 Emulator.zip to the root of your device and soft reset. I tried to make a CAB file, but installing it always failes, haven't got a clue why. If anyone find a way to create this cab file, please let me know.
Best way to use this if BT is disabled by default. And it's not necessary to enable the auto launch of NaviPanel. I don't use it anymore. It disables the StartMenu hardkey, and since I don't use CoPilot it doesn't do much for me. By using these utilities I do have true landscape support for the dialer, and I works with any AC power connection, no need to modify the USB connector. I'm very happy, my in car experience is 100% better now.
Hope this helps anyone, if not I'm still happy, it works for me!
Cheers,
/Cacti
le_cactus said:
CarKitMode Detect Helper.exe - A modified file that is originaly used by the Via Michelin GSP software. It detects if AC Power is connected of disconnected, and the launches my HTC_car_kit_mode_auto.exe. It either launches with the AC_ON or AC_OFF parameter, depending on wheter AC is connected or disconnected.
CarKitMode Detect Helper.lnk - The shortcut that is placed in \Windows\StartUp to autostart the monitoring of te AC connection.
Click to expand...
Click to collapse
Hi,
unfortunately this wont work on my ROM. I use original german ROM with all updates. If I copy your "Startup" shortcut to my "Autostart" folder I get an error message, that the application is not certified or some components are missing. I already dissabled the "uncertified" message with HD2Tweak and it works for other apps.
Best regards
extrapurifier said:
I get an error message, that the application is not certified or some components are missing.
Click to expand...
Click to collapse
Hi,
At what point does the error message occur? At startup (while launching CarKitMode Detect Helper.exe) or when connecting or disconnecting power?
Cheers,
/Cacti
le_cactus said:
Hi,
At what point does the error message occur? At startup (while launching CarKitMode Detect Helper.exe) or when connecting or disconnecting power?
Cheers,
/Cacti
Click to expand...
Click to collapse
At StartUp. Maybe it's because I use german ROM?

how to detect a bluetooth connection

hello,
i search a solution to detect a bluetooth connection, device is equal.
all what i found is getBondedDevices() from BluetoothAdapter, but pairing this is not a connection...
thanks 4 help
Solved!
i use ACTION_ACL_CONNECTED and ACTION_ACL_DICONNECTED from class BluetoothDevice.
Code:
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));
Android-Wireless
Helo Sir,
How to switch On Bluetooth and Wireless programatically? Even i can't switch on bluetooth and wireless manually in android.
Emulator shows error.
dineshsubramanian said:
Helo Sir,
How to switch On Bluetooth and Wireless programatically? Even i can't switch on bluetooth and wireless manually in android.
Emulator shows error.
Click to expand...
Click to collapse
Emulator actualy dosn't support Bluetooth, WLan and GPS!
CodeFlatter said:
i use ACTION_ACL_CONNECTED and ACTION_ACL_DICONNECTED from class BluetoothDevice.
Code:
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));
Click to expand...
Click to collapse
This only works if the device isn't yet connected. If the device is ALREADY connected when your app starts, how do you detect that, without starting a discovery?
been searching for a few days for an answer to this. Anyone got one?
Thanks
Scott
No one has any ideas on this? A month of searching has so far proven futile, but I can't believe it's not possible...
On the Google android developers site there is a complete example (a bluetooth chat).
http://developer.android.com/intl/de/resources
Hi!
I'm trying to connect my phone (HTC desire running Opendesire last update or HTC stock 2.2) to a serial to bluetooth converter module.
It seems to me that BluetoothChat sample is a good point to start as this application sends bytes over bluetooth.
That's just what i want to do: send some bytes from phone, receive some bytes from the module
I tried to run the Bluetoothchat sample on my phone:
Discovering and pairing the module is ok, but I'm unable to open a connection.
Anyone ever tried (and get success) to do same things as me?
Thank you.
Delvorak said:
This only works if the device isn't yet connected. If the device is ALREADY connected when your app starts, how do you detect that, without starting a discovery?
been searching for a few days for an answer to this. Anyone got one?
Thanks
Scott
Click to expand...
Click to collapse
Take a look at my SpeakerProximity Project => http://code.google.com/p/speakerproximity/
I faced the same problem and the solution that fitted the best was using BT connect/disconnect receivers that always get triggered and update a shared preference.
Hi,
I'm still having some issue with the bluetoothchat sample from sdk and bluetooth to serial converter module.
Now it works fine with AOSP rom but i'm still unable to make connection with HTC stock rom.
I've tried with a friend to run the application on a galaxy spica and we had the same issue. First the application didn't even start on spica and we had to change permissions to avoid Force Close.
Somebody knows what's wrong with bluetooth and HTC or Samsung?
Thank you
detecting bluetooth STATE_ON
in your OnStart() use :
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null) //if null device does not support bluetooth
{
if (mBluetoothAdapter.getState()==BluetoothAdapter.STATE_ON) {
//do stuff
}
}
I use a bluetooth listener for the STATUS_CHANGED event to check if BT is switched on.
If so, i enable my scanning avtivities, else i disable them.
Greetz,
Mike
STATE_ON is not the same as connected, though. (I think).
Personally, I've be having trouble figuring out the disconnect event to listen for, but I think the ACL one is what I need. Will try to remember to post back if I get it working. Damn WiFi process always interupts my transfers epecially when email decides it's time to sync.
Anyways, one tip for those having trouble with the BluetoothChat example is that for some reason you dont want to be listening for a connection at the same time as trying to make one. If you try the BluetoothChat example it actually almost always fails to connect. But if you make sure only one device is using listenforRfcomm... and the other is connecting, you'll connect fine.
The Spica thing is some bug with that phone specifically, though I think some people have solved it with some type of strange method reflection. Check stackoverflow for spica/bluetooth.
Just an update for my problem the ACL braodcasts were just what I was looking for though the diconnect broadcast is sometimes very slow to trigger.

Bluetooth PAN Client stops functioning...

Hi,
After 4 months of good job ,the bluetooth PAN client function stopped working..
I have always used this function to connect my Leo to an Internet adsl pc.(via BT)
Also tried to join again the bluetooth pc with Leo....but did not work ....
So I ask you if you encontered this strange problem.
Maybe some registry settings damaged.....or something like that..
Shall I hard reset ??
Thanks ,regards

LED Bluetooth connect

I've bought a bluetooth RGB led strip for my car on ebay, it comes with an app that connects to it.
The thing is the app is slow, buggy and lacks options.
I dev'd previously in lua and python and nothing else but I want to try and make my own app for the strip, the problem is that it never finds it even with inbuilt phone bluetooth or other BT apps.
I have no idea what it is built on so I looked for arduino BT control, didn't find the device.
Bluetooth reader (read data sent and received) and never found the device either.
But its app? Automatically pairs up with it.
I've decompiled and source and read through it, it uses UUID which I don't know anything about so it makes me thing this is the reason it never finds the strip.
This is what I believe handles all the BT process: http://pastebin.com/0zbKZF9d
Any input is appreciated.
Hello!
The device can be seen in the Bluetooth configuration of your cell phone?
The UUID is composed by long values (like 0x12345678,0x9ABCDEF) and it's used to define an application. To work, the server and the client must use the same UUID.
If you have the UUID value, then you can do a reverse engineering to understand who the app sends the commands to the leds strip.
You can create a server Bluetooth simulating the led strip (using the same UUID) and connect the app to it.
I hope this will help

Categories

Resources