Android Question Events

Nizze

Active Member
Licensed User
Longtime User
Hi

I have a Android unit that have som extra buttons .
Not menu and home , just some extra buttons for applications .

What is the way to find the events for this buttons ??
I want to use this buttons in my app .

Br Nisse
 

Nizze

Active Member
Licensed User
Longtime User
This code does not give me any info
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    ToastMessageShow(KeyCode,True)
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What device is that?
 
Upvote 0

Nizze

Active Member
Licensed User
Longtime User
I think you have to create a BroadcastReceiver which listen to android.intent.action.MEDIA_BUTTON.
for BroadcastReceiver see this thread: https://www.b4x.com/android/forum/threads/broadcastreceiver.12493/

Okey

Is this the code needed ??
B4X:
Sub Service_Start (StartingIntent As Intent)
   Broadcast.addAction("android.intent.action.MEDIA_BUTTON")
   Broadcast.SetPriority(2147483647)
   Broadcast.registerReceiver("")
End Sub

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

Becuase i cant se anything

Br
Hans
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
did you add something like
B4X:
AddReceiverText(MyService, <intent-filter>
    <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>)
to the manifest?
 
Upvote 0

Nizze

Active Member
Licensed User
Longtime User
Like this ??

did you add something like
B4X:
AddReceiverText(MyService, <intent-filter>
    <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>)
to the manifest?
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddReceiverText(MyService, <intent-filter>
    <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

I get an error on MyService , What should it be ?
I have never used Manifest Editor before
 
Last edited:
Upvote 0

Nizze

Active Member
Licensed User
Longtime User
In my log i can read :

in th logs i can se this :

03-30 12:28:11.704 D/WindowManager( 854): interceptKeyTq keycode=222 screenIsOn=true keyguardActive=false policyFlags=a000001 isWakeKey=true
03-30 12:28:11.704 V/WindowManager( 854): Broadcast ACTION_PTT_BUTTON_DOWN event
03-30 12:28:11.704 D/WindowManager( 854): interceptKeyTi keyCode=222 down=true repeatCount=0 keyguardOn=false mHomePressed=false canceled=false
03-30 12:28:12.605 D/WifiNative-wlan0( 854): doString: SIGNAL_POLL
03-30 12:28:12.625 D/WindowManager( 854): interceptKeyTq keycode=222 screenIsOn=true keyguardActive=false policyFlags=2000001 isWakeKey=true
03-30 12:28:12.625 V/WindowManager( 854): Broadcast ACTION_PTT_BUTTON_UP event
03-30 12:28:12.625 D/WindowManager( 854): interceptKeyTi keyCode=222 down=false repeatCount=0 keyguardOn=false mHomePressed=false canceled=false

03-30 12:28:13.486 D/WindowManager( 854): interceptKeyTq keycode=222 screenIsOn=true keyguardActive=false policyFlags=a000001 isWakeKey=true
03-30 12:28:13.486 V/WindowManager( 854): Broadcast ACTION_PTT_BUTTON_DOWN event
03-30 12:28:13.486 D/WindowManager( 854): interceptKeyTi keyCode=222 down=true repeatCount=0 keyguardOn=false mHomePressed=false canceled=false

03-30 12:28:14.437 D/WindowManager( 854): interceptKeyTq keycode=222 screenIsOn=true keyguardActive=false policyFlags=2000001 isWakeKey=true
03-30 12:28:14.437 V/WindowManager( 854): Broadcast ACTION_PTT_BUTTON_UP event
03-30 12:28:14.437 D/WindowManager( 854): interceptKeyTi keyCode=222 down=false repeatCount=0 keyguardOn=false mHomePressed=false canceled=false
03-30 12:28:15.368 D/LogSystem(28697): Clicked stop

So if anyone can help , then i'm happy ..

//Nizze
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
After a long search i managed to fix it !! Now it is working

Your solution might help other members in the future ... Many thanks.
 
Upvote 0
Top