Android Question clipboard buffer copy, initiate intent (my app)

GudEvil

Member
Licensed User
Longtime User
hi there,
I had a requirement that whenever user copies any text or sms or something like that.(anywhere/ in any app)

copied data is temporary stored to clipboard_buffer.
I want to initiate a intent or event or should start my app n save that copied text to my_app. or something floating widget

please share your thoughts here or any other way around.

P.S. I can manually open my app n paste there, but it is long procedure for long run n some time consuming to novice users.

thanks
 

Ohanian

Active Member
Licensed User
Longtime User
Hi,

Here's another way, just set a Clipboard Change Listener and you don't need to use a timer (use this in a service)

B4X:
Sub SetClipListener
    Dim R As Reflector
    Dim Cjo As JavaObject = R.GetContext
    Cjo = Cjo.RunMethod("getSystemService",Array As Object("clipboard"))
    Dim Listener As Object = Cjo.CreateEvent("android.content.ClipboardManager.OnPrimaryClipChangedListener","ClipChanged",False)
    Cjo.RunMethod("addPrimaryClipChangedListener",Array(Listener))
End Sub

Sub ClipChanged_Event(MethodName As String, Args() As Object)   
    Dim ClipBoard As BClipboard
    Dim sLink As String = ClipBoard.getText
end sub
 
Upvote 0
Top