BTadmin

raye

New Member
Licensed User
Longtime User
Hi All im a newbie here. I am trying to get to grips with B4A and i am using some code from the following thread..................

http://www.b4x.com/forum/basic4andr...oid-bluetooth-bluetoothadmin-tutorial-11.html

This is the code in question...............
Sub btnAllowConnection_Click
'this intent makes the device discoverable for 300 seconds.
Dim i As Intent
i.Initialize("android.bluetooth.adapter.action.REQUEST_DISCOVERABLE", "")
i.PutExtra("android.bluetooth.adapter.extra.DISCOVERABLE_DURATION", 300)

StartActivity(i)
serial1.Listen
End Sub

What i would like to happen is when the "allow connection" button is pressed then NO pop up screen (bluetooth permission request) appears asking the user to make the phone discoverable. Insead the phone becomes discoverable for x seconds WITHOUT user intervention.

Any help would be great.

Cheers
Ray
 

raye

New Member
Licensed User
Longtime User
OK after a bit of searching around it would seem that there is no way to avoid the "bluetooth permission request" pop up message that appears when you do the following.

B4X:
Dim i As Intent
i.Initialize("android.bluetooth.adapter.action.REQUEST_DISCOVERABLE", "")
i.PutExtra("android.bluetooth.adapter.extra.", 0)

StartActivity(i)
serial1.Listen

Seems a bit strange but im guessing it has something to do with bluetooth security...............or is there some work around? HELP!

I did learn that putting a 0 in DISCOVERABLE_DURATION keeps the app in an "always discoverable" state.

Ray
 
Upvote 0

raye

New Member
Licensed User
Longtime User
OOPS...........typo on the last post :0

B4X:
Dim i As Intent
i.Initialize("android.bluetooth.adapter.action.REQUEST_DISCOVERABLE", "")
i.PutExtra("android.bluetooth.adapter.extra.DISCOVERABLE_DURATION", 0)
 
Upvote 0
Top