Android Question How to monitor key values globally in class library?

cxbs

Active Member
Licensed User
Longtime User
hello everyone!

I have a class library that needs to monitor key values in the background

I've been looking for it in the forum for a long time, only the one with activity has been found

But after using the customlayoutdialog cannot receive the key values!

I do not know if there are other better ways, thank you!

KeyPress:
Sub Activity_KeyDown(Keycode As Int, KeyEvent As Object)
    Dim jo As JavaObject = KeyEvent
    Dim c As Int = jo.RunMethod("getUnicodeChar", Null)
    If c > 0 Then
        Log(Chr(c))
    End If
End Sub

#if Java
public boolean _onkeydown (int keyCode, android.view.KeyEvent event) {
   processBA.raiseEvent(null, "activity_keydown", keyCode, event);
   return false;
}
#End If
 

Attachments

  • GetKeyPress.zip
    9.1 KB · Views: 130
Last edited:

JohnC

Expert
Licensed User
Longtime User
Are you looking to detect key presses *from any activity in your app* while your app is running in the foreground, or are you looking to detect key presses for other apps?

If for other apps, then that would be very dangerous for the user's privacy.

You may be able to do it using Accessibility permissions, but I doubt you will be able to publish the app in the play store without a good reason why you need to capture keystrokes in the background.
 
Upvote 0

cxbs

Active Member
Licensed User
Longtime User
Are you looking to detect key presses *from any activity in your app* while your app is running in the foreground, or are you looking to detect key presses for other apps?

If for other apps, then that would be very dangerous for the user's privacy.

You may be able to do it using Accessibility permissions, but I doubt you will be able to publish the app in the play store without a good reason why you need to capture keystrokes in the background.

Hello, Johnc!

It's my app key value

How to do it?
 
Upvote 0
Top