Android Question BClipboard - not working correctly when app is in background

artsoft

Active Member
Licensed User
Longtime User
Hi all!

In my app there is a timer which deletes the content of the clipboard (clears it) after its last tick.

To delete the clipboard, I use this command:

B4X:
    Dim c As BClipboard
    c.clrText

It works great. I also add a BEEPER (sound lib) to my timer, so I can hear that the timer works also when the app is running in the background.

So far .... so good!!

BUT:
When my app is running in the background and I hear the last beep, then I assume that the clipboard is deleted. But this is not the case!

While the beeper is sounding, I can insert in a text app the content of the clipboard.
But the clipboard is only deleted when my app is in the foreground. When the last beep was generated and the timer has finished his work, then the clipboard is empty.

So, I am asking myself, whats wrong in case of background running?

Regards
ARTsoft
 

artsoft

Active Member
Licensed User
Longtime User
As Clipboard is using a text shared from a UI-Object i fear it only make sense to use it when the app is in foreground.

Thanks for your quick response!

But then there should also be a basic function that can delete the clipboard system-wide. And not with the help of the clipboard object of my app.

Regards
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
I imagine using a foreground service would help also.

Thanks. Yes, I already was thinking of that. This could really help!

First I will try working without the lib. Only working with the reflector.

We will see!

Regards
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
I can see that our lib BClipboard is working with this class:

android.text.ClipboardManager

Added in API Level 1. This class was deprecated in API level 11. Old text-only interface to the clipboard. See ClipboardManager for the modern API.

What do you think? Is there a need to update this lib?

Because the function:
setText(CharSequence text)

is also deprecated in the new ClipBoardManager.

Google said that setPrimaryClip(android.content.ClipData) should be used instead.

Regards
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
I imagine using a foreground service would help also.

The code is now completely in my starter service.
How to set this service to foreground?

I am asking because I have the same result: No deletion of the clipboard content, when app is in backgound :-(

Regards
ARTsoft
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
How to set this service to foreground?
Solid example:
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…