Android Question Intent receiver for hardware PTT button - SOLVED

Gandalf

Member
Licensed User
Longtime User
Hi,

I'm trying to make intent receiver for detecting PTT button press on specialized Android device (Estalky E966) which has hardware PTT button. Android version is 8.1. According to manufacturer, intents are "android.intent.action.PTT.down" and "android.intent.action.PTT.up". I tried static receiver:
Manifest:
AddReceiverText(ptt,
<intent-filter>
    <action android:name="android.intent.action.PTT.down"/>
</intent-filter>)
Service:
Sub Service_Start(startingIntent As Intent)
    If startingIntent.Action = "android.intent.action.PTT.down" Then
        ToastMessageShow("PTT down", False)
        Log("PTT down")
    End If
    Service.StopAutomaticForeground
End Sub

and dynamic receiver:
B4X:
#Region  Service Attributes
    #StartAtBoot: True
#End Region

Sub Process_Globals
    Private nid As Int = 1
    Private lock As PhoneWakeState
    Private BR As BroadCastReceiver
End Sub

Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
    lock.PartialLock
    BR.Initialize("BroadcastReceiver")
End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StartForeground(nid, CreateNotification("..."))
    StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
    BR.addAction("android.intent.action.PTT.down")
    BR.addAction("android.intent.action.PTT.up")
    BR.SetPriority(998)
    BR.registerReceiver("")
    Log("Service start Ok")
End Sub

Sub CreateNotification (Body As String) As Notification
    Dim notification As Notification
    notification.Initialize2(notification.IMPORTANCE_LOW)
    notification.Icon = "icon"
    notification.SetInfo("PTT", Body, Main)
    Return notification
End Sub

Sub Service_Destroy
    lock.ReleasePartialLock
End Sub

Sub BroadcastReceiver_OnReceive (Action As String)
    ToastMessageShow(Action,False)
    Log(Action)
    'can only abort when sendOrderedbroadcast Is called.
    'BR.AbortBroadcast
End Sub

And none of them worked. Any advice?
 

Gandalf

Member
Licensed User
Longtime User
I have contacted the manufacturer and got comprehensive explanation of my problem. Estalky E966 is equipped with separate DMR radio supported by it's own eDMR app which can't be uninstalled. This app was intercepting PTT button intents. Fortunately there is a switch in that app which disables intent interception. Static receiver started to work immediately, dynamic receiver worked too after this small correction.
 
Upvote 0
Top