Problem with Bluetooth Connection - Java for Android App Development

Hi guys,
I have a problem with my bluetooth connection and have no idea how to solve this.
Following:
My App does not know, when the device disconnected due to standby of the device. I have set Intents for a disconnected bluetooth connection, but when my device is asleep, then the Handler does not get triggered by the intent.
I dont know how to solve this problem, should i just try to reconnect the device always?

nick9090 said:
Hi guys,
I have a problem with my bluetooth connection and have no idea how to solve this.
Following:
My App does not know, when the device disconnected due to standby of the device. I have set Intents for a disconnected bluetooth connection, but when my device is asleep, then the Handler does not get triggered by the intent.
I dont know how to solve this problem, should i just try to reconnect the device always?
Click to expand...
Click to collapse
Why don't make handler get status in per second it will update it is better from broadcast receiver if you need help in handler pm me okay
Sent from my SM-G530H using XDA Free mobile app

I solved my problem now, by trying to reconnect every onResume() in the background. In my MainActivity i have a BluConStatus which is true or false. By the First time connecting it gets true. After then I check it in onResume(). If this BluConStatus is true I try to reconnect. If it fails the connection is still active, if not it is connected again. Everything works fine in the background so the user does not get informations about the reconnecting function.

nick9090 said:
I solved my problem now, by trying to reconnect every onResume() in the background. In my MainActivity i have a BluConStatus which is true or false. By the First time connecting it gets true. After then I check it in onResume(). If this BluConStatus is true I try to reconnect. If it fails the connection is still active, if not it is connected again. Everything works fine in the background so the user does not get informations about the reconnecting function.
Click to expand...
Click to collapse
Could I get java code so it will easy to understand the code
Sent from my SM-G530H using XDA Free mobile app

Related

Wifi over 3G

Hey,
I have a seemingly simple problem. I use POP email and I want to check for emails regularly but at home and work I can stay connected to a WiFi network.
I know with Skype I can set the program to use WiFi if available else 3G. Does anyone know if this can be done at a system level so for instance that email and any other apps needing a connection will follow this protocol, please?
Thanks.
Since i do not want to create a new thread (for 2 posts maximum) i will ask here: my phone shows that is connected with the wi-fi (usr9108 router--> access point) BUT when i am trying to sign in to msn, skype open a page in I.E nothing happens, it's like i am not connected to the net.
MetalMushroom said:
Hey,
I have a seemingly simple problem. I use POP email and I want to check for emails regularly but at home and work I can stay connected to a WiFi network.
I know with Skype I can set the program to use WiFi if available else 3G. Does anyone know if this can be done at a system level so for instance that email and any other apps needing a connection will follow this protocol, please?
Thanks.
Click to expand...
Click to collapse
Most applications will use whatever connection is already on. In your case if you are connected via WiFi then your email will use that connection, if not then it will try to connect by the default GPRS/3G connection setting. I do this all the time.
Okay, yeah sorry.
To clarify I think what I really want is to let the device go into sleep mode and attempt to create a WiFi connection before it attempts to create a 3G data connection.
Other than that, purchasing a cradle and leaving the device in alert mode would be the way forward would it?
Is there a way for WiFi to remain on even if the device is in Sleep mode?
Thanks again.
MetalMushroom said:
Okay, yeah sorry.
To clarify I think what I really want is to let the device go into sleep mode and attempt to create a WiFi connection before it attempts to create a 3G data connection.
Other than that, purchasing a cradle and leaving the device in alert mode would be the way forward would it?
Is there a way for WiFi to remain on even if the device is in Sleep mode?
Thanks again.
Click to expand...
Click to collapse
Oh I see you what you mean. Why not try this schedule an event to wake the device and so long as it was connected to a wireless AP when it went to sleep it will try to reconnect when it wakes then schedule another event after a suitable pause to allow it to find and connect to AP to sync email.
Alternatively try SKSchema or MortScript which are both macro tools to do the above.
Cheers Jazza. Not sure how to 'schedule' an event but I'll do some research into 'SKSchema or MortScript' to see how I can use them.
Thanks for your help.

Keeping Internet connection Alive (Ping)

I have been using a dialing CDMA cell over bluetooth for internet access from BlackStone.
The connection goes dormant after 10 sec inactivity. Each wake up from dormancy is charged a new call
Is there any app (preferably freeware) that constantly pings a public server say yahoo.com in background to keep the connection Alive?
crajee said:
I have been using a dialing CDMA cell over bluetooth for internet access from BlackStone.
The connection goes dormant after 10 sec inactivity. Each wake up from dormancy is charged a new call
Is there any app (preferably freeware) that constantly pings a public server say yahoo.com in background to keep the connection Alive?
Click to expand...
Click to collapse
HD Tweak has this ability just download and install and check what you want your phone to do I believe it has the option to remain connected when phone sleeps
Thanks for that ... I already have it.
Here the problem is not HD going to sleep but the external phone data connection... So I need to ping it repeatedly. I do on desktop with the ping command. (and earlier in my palm PDA by a IM client for Jabber).
Now on PPC I am lost. I tried an app called GPRS keep alive for WM5 but doesn't seem to work well on WM6 of THD.
ozmoran said:
HD Tweak has this ability just download and install and check what you want your phone to do I believe it has the option to remain connected when phone sleeps
Click to expand...
Click to collapse
Do you found a solution for the disconnect problem? At the moment I use "hrping -t -s 5000 google.de" at my desktop or vxUtils directly on the TouchHD.
vxUtils unfortunately makes the device so slow/unresponsive as to be useless. (looks like some incompatibility with the graphics processing of HD becuse CPU utilisation is not high).So still looking for a useable solution.
Hopefully some one writes a simple pinging utility... My service provider is minting money by data calls every 20-30 sec!!

wifi drops

I have a tattoo for a couple of days and my wifi connection drops out every few minutes. Have searched around xda and google but haven´t found an answer that worked/helped.
I have wireless router in my house. We don´t have any free wifi connections around city so i don´t how it behaves on other connections.
Did anyone found any kind of a solution for this?
What's your router model?
Wifi Drops
Same problem here i got a Netgear WNR2000
have you tried your router's connection with any other device ? (ex. a laptop or another cellphone? ) 'cause it might be a router connection problem
I haven´t tried it with other devices i will do so... It´s Huawei echolife HG520b
djhancks said:
have you tried your router's connection with any other device ? (ex. a laptop or another cellphone? ) 'cause it might be a router connection problem
Click to expand...
Click to collapse
i tried 4 laptops and 2 printers to wifi ( works well
I have also been having this issue over the past couple of days. It has worked fine since I bought the phone last month and now the wifi connects and then starts searching again immediately. The router is working fine with laptops and ps3 and another desktop in the back of the house. Im sitting right beside the router now with the signal showing full bars but instantly looping into the search mode and dropping connection. Have soft reset several times and nothing. Also does it with a friends router.
What's the deal here? Is there a fix or a setting im missing?
Att Tilt2
Energy.RHODIUM.23554.Sense2.1.Apr.09
I have tried my friends laptop and nokia E65 phone and both worked without any problem!
So it seems to be android problem...
I have tried many things that I´ve found on google site and other forums and nothing helped.
Have been changing chanels, security, firewall, hard reset the phone etc. and always the same-every couple of minutes it loses connection!
It seems to be the problem with android 2.1 also....
Hope that someone has a valid solution (and soon)
I had the same problem as all of you. Some times the internet connection was fine and other it simply droped and I couldn´t even find the connection in the setings..
So I asked in a Portuguese forum what could I do to solve the problem and I was advised to use the app 'fix my Wifi'.. I have to say it worked perfectly. It needs some time to understand the problem (some drops will hapen at the begining), but when it understands, the problem disapears.. Until this moment, it never droped again.. I advise you all to use it..
Hello from Slovenia!
Same problem with wifi. I checked the wifi fixer, but i dont know how to do with this app.
I cant click on start or ok, when i start the app, because the text is over the button.
I´ve got DL-524, and sometimes it works perfect, that stop working for 30sec maybe, and then work and then again stop.....
VERY MAD !
Greetings
Hello.
What it says in the begining is that you need to select 'never' in the wifi setings, the part where you choose when does the wifi turns off. Don't worry, use a wiget to turn wífi off when you don't need it..
Then just leave it on, it will fix, in time, your wifi problem. Whit me worked perfectly..
-------------------------------------
Sent via the XDA Tapatalk App
Silu_Donerbar said:
Hello.
What it says in the begining is that you need to select 'never' in the wifi setings, the part where you choose when does the wifi turns off. Don't worry, use a wiget to turn wífi off when you don't need it..
Then just leave it on, it will fix, in time, your wifi problem. Whit me worked perfectly..
-------------------------------------
Sent via the XDA Tapatalk App
Click to expand...
Click to collapse
I change it manual, to always on. So just start the problem and turn on wifi and check if somethink happened
I think, that app Wifi Fixer, isnt for the HTC Tattoo. It stops all the time, screen is not in the right dimension, its buggy.
Force close, when try to activate it
Any other ideas?
I try :
- No security, open network ( Same problem )
- No Mac Filter
- WPA Personal TKIP
- WPA2 Personal
I change everything but, still problems
((( Sad
That is very strange, because i have a tattoo (i'm writing in it this moment!) and i'm using the app.. it works fine, no screen problems. I open it (and an icon appears in the tab bar) and i dont have to do anything else.. It really woks great, the connection never failed again and, as i said, i'm using it and it didmt go down. Before thist app, thist was impossible..
-------------------------------------
Sent via the XDA Tapatalk App
But when you start the app, i get on the tab bar, response like thank you for using ...... etc. but when i go to the program, the main screen is bad, About button and Ok, are got, but the active is in the middle of the text. Text is over the button. Heh strange
That ís very strange. But you dont need to go to the main menu. Just make sure the icon is in the tab bar. Then just wait for the app to do is job.. as i said, it will take some time..
-------------------------------------
Sent via the XDA Tapatalk App
Hello!
I tested app, yesterday evening, and I think that app really help. I will test it today again, becouse yesterday i can browse normal via Wifi, with no problems.
we will see
I hope your problem is fixed.. allways have it on and i dont think it should be any more troubles..
-------------------------------------
Sent via the XDA Tapatalk App
Hello again
My final conclusion is, that i have to change the router!
I try friends Linksys WRT54GL and wifi works very fast with no problems!
So 1 hour ago, i buy this router, and the problem is fixed
Greetings!
nobody needs a new router just a program called connectify and a wifi dongle or card or a laptop with built in wifi read my post in click android development labeled wifi drop fixed
read my thread http://forum.xda-developers.com/showthread.php?t=697021

[Update]Bluetooth Issue, freeze my TAB

hi
Im running the stock JK6 and rooted.
when Im running e.g. the liveview app my phone keeps some kind of freezing after a few minutes, first I tought it is app related but now I revieved my OBD2 scanner for my car and its just the same with the app "torque".
is this a hardware related problem or something wrong with this ROM.
did a HR several times and reflashed the ROM.
Edit: I noticed when bluetooth recieve or send data I cant get any other wireless date like on wifi or on radio.
please help
Seems to be a one time event with the data problem but the main thing keeps annoing me
Have you tried pulling the battery waiting 60 seconds placing the battery back in the phone and then rebooting?
Eh no cause on the galaxy tab the battery cant be removed
NightFire123 said:
hi
Im running the stock JK6 and rooted.
when Im running e.g. the liveview app my phone keeps some kind of freezing after a few minutes, first I tought it is app related but now I revieved my OBD2 scanner for my car and its just the same with the app "torque".
is this a hardware related problem or something wrong with this ROM.
did a HR several times and reflashed the ROM.
Edit: I noticed when bluetooth recieve or send data I cant get any other wireless date like on wifi or on radio.
please help
thanks
Click to expand...
Click to collapse
I don't Know, but if you have a Bluetooth PAN connection to the internet, then it should be not possible to have another connection to the internet. IP routing to the gateway would be confused if you could.
There are tools that "group" several separate internet connections into one virtual one.
no Im not using a bt PAN to connect the inet, only normal bluetooth data usage
Push
Just only me who is facing this annoing problem?
Same problem with OBD2 :s disable GPS reduc freeze loop. But not fully (30 minutes). Next time i will turn off Data conection.
Every time i've freeze now i see torque try reconnect to OBD2, seem like BT of SGT turned off or time out
I am having the same problem. As long as I have bluetooth turned on, it will hang the Tab within 30 min. All bluetooth connections are definitely gone. Turning off the bluetooth won't help. The only way is to reboot and never turn bluetooth on.
BTW, I have tried connecting LiveView or a normal bluetooth headset. Both cause the same problem.
I am on JK2.
It seems it is bluetooth driver conflicting with any other data connections.
Did a further testing. Disabled Wifi, but doing data communication via 3G network while turning bluetooth on. The tab hangs in a few minutes. Found a process called 'btld' sucking up all the CPU circle.
Any ideas what 'btld' is?
Thought this should not be a hardware problem because bluetooth works fine when all data connections are off and Wifi/3G data works fine when bluetooth is off. It must be some sort of default setting isn't correct. If this is the case, then root would be a must before manually tuning any parameters.
Found root cause. It is actually the SonyEricsson LiveView software causing troubles. After removing, everything goes well.
Checked on SonyEricsson's web site, it seems Froyo is yet to be supported.
try to use WO Webcam B-Lite out of market, you can open a bt connection by pressing activate and then while running, close via taskmanager, voila the freeze begun
I've got galaxy Tab and galaxy S, and torque badly freezes the devices almost every time I exit the application. It cannot be an hardware fault since I use lot of bluetooth devices and always 3g connected, never had issues. Just with torque, and I don't have any "sony liveview" thing.
Reading on the comments of Torque it seems that also other devices have the same freeze issue (especially a phone called "Evo 4G"). Many months ago I sent a mail to the developer explaining the bug but he bumped me away replying that the app is tested and working on GalaxyTab (and obviously it's not true, or he did some mistake in testing). Now lots of people with this Evo 4G are complaining and the developer is trying to fix. let's hope..

WiFi tethering issue

I know this is not exactly Android head unit topic but it's closely related to using the device.
So here's what's going on. When I manually turn on wifi tethering (Hotspot) on my phone (NOA H10, 7.1.1 nougat), device (head unit) connects to it as it should, and everything works.
On the otherhand when I use tasker, or any other app to trigger wifi tethering on Bluetooth connection, the hotspot turns on but device can't connect to it. I get obtaining IP address issue, and when I set to static IP it connects for a few seconds and then drops the connection. It's really frustrating because I know it can work.
I know l can always turn the hotspot on manually when I get into the car but I want it to be automatically turned on when Bluetooth connects to my unit.
Anyone else has/had this kind of issues? Any ideas/solutions?
AFAIK most of these units don't support bluetooth tethering at all. Not really sure if any do at all.
Sent from my iPhone using Tapatalk
I'm not talking about bluetooth tethering.
Ok I get it, trigger wifi on bluetooth connection with the triggering attempted on the phone side.
I have 0 experience with android phones but I know my iphone will never allow a connection (to anything) unless you open the hotspot setting manually. When I do that my units all automatically connect.
Sent from my iPhone using Tapatalk
I use Macrodroid app to activate the hotspot when muy phone is conected by bluetooth, and all runs ok
I tried macrodroid. Same thing as the other apps. It turns on hotspot but can't connect to it.
So here's the SITREP, when I use connected to a bluetooth device trigger without specifying a device, the hotspot works. Only if variable, device name and/or mac address is specified the device will not connect to hotspot.
Install and use this plugin
Doesn't work. But I managed to get it work with secure settings and touch task plugins.
Tux2609 said:
Doesn't work. But I managed to get it work with secure settings and touch task plugins.
Click to expand...
Click to collapse
Can you elaborate please? I'm also having this EXACT same issue.
Thanks.
jks8496956 said:
Can you elaborate please? I'm also having this EXACT same issue.
Thanks.
Click to expand...
Click to collapse
I'm using secure settings and touch task Tasker plugins to simulate manual hotspot toggle. When my phone connects to my headunit it triggers screen on then screen unlock to unlock the phone, then quick settings (drop down) menu and finally touch on hotspot tethering icon. Same command is executed on Bluetooth disconnected status.

Categories

Resources