Android Question ACTION_ACL_DISCONNECTED doesn´t fire

Humberto

Active Member
Licensed User
Longtime User
I read all threads for bluetooths and I did to different service to hold the Connect and Disconnect intent but I just receive the Connect intent.

Bellow is my manifest
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.
AddPermission(android.permission.BLUETOOTH)
AddReceiverText(detect_bluetooth, <intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
</intent-filter>)
AddReceiverText(disconnect_bluetooth, <intent-filter>
<action android:name="android.bluetooth.device.action.ACTION_ACL_DISCONNECTED"/>
<action android:name="android.bluetooth.device.action.ACTION_ACL_DISCONNECT_REQUESTED"/>
</intent-filter>)

AddReceiverText(detect_bluetooth, <intent-filter>
    <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>)
AddReceiverText(detect_bluetooth, <intent-filter>
    <action android:name="android.media.VOLUME_CHANGED_ACTION" />
    </intent-filter>)

follow the service

B4X:
Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim Ini_Conf As KeyValueStore

End Sub
Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
      Log ( "Verificando ..." )
    Log(StartingIntent)
    Log(StartingIntent.ExtrasToString)
         If StartingIntent.Action = "android.bluetooth.device.action.ACTION_ACL_DISCONNECTED" Then
         Log ( "Bluuetooth desconectado")
            Ini_Conf.Initialize(File.DirDefaultExternal,"Ini_Conf")
         Ini_Conf.PutSimple ("Blue_Name","" )
         Log ( "Bluuetooth desconectado")
    End If    

End Sub

Sub Service_Destroy

End Sub

Someone can help ?
 

Humberto

Active Member
Licensed User
Longtime User
Hi Erel

I tryed and doesn´t work.

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.
AddPermission(android.permission.BLUETOOTH)
AddPermission(android.permission.BLUETOOTH_ADMIN)
AddReceiverText(detect_bluetooth, <intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
</intent-filter>)
AddReceiverText(disconnect_bluetooth, <intent-filter>
<action android:name="android.bluetooth.device.action.ACTION_ACL_DISCONNECTED"/>
<action android:name="android.bluetooth.device.action.ACTION_ACL_DISCONNECT_REQUESTED"/>
</intent-filter>)

AddReceiverText(detect_bluetooth, <intent-filter>
    <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>)
AddReceiverText(detect_bluetooth, <intent-filter>
    <action android:name="android.media.VOLUME_CHANGED_ACTION" />
    </intent-filter>)
 

Attachments

  • blue.zip
    11 KB · Views: 185
Upvote 0

Humberto

Active Member
Licensed User
Longtime User
Erel

Many thanks, work

Just to know, you can use one service to detect on and off the bluetooth connection

Humberto
 
Upvote 0
Top