ClearClipboard - Clipboard Management

This extension provides comprehensive tools for managing the clipboard content on Android devices. It allows users to perform various clipboard operations such as clearing, setting, getting, and monitoring clipboard content.


component_method (4)

  1. ClearClipboard
    • Clears the clipboard content by overwriting it with multiple large strings, followed by an empty string.

  1. ClipboardCleared
    • Event triggered when the clipboard is successfully cleared.

  1. GetClipboardContent
    • Retrieves and returns the current text content of the clipboard.

  1. SetClipboardContent
    • Parameter: String text
    • Sets the provided text as the clipboard content.

  1. ClipboardContentSet
    • Event triggered after setting the clipboard content.

  1. IsClipboardEmpty
    • Checks and returns whether the clipboard is empty.

  1. ClearClipboardCompletely
    • Clears the clipboard content completely and triggers an event.

  1. AddToClipboard
    • Parameter: String text
    • Adds the provided text to the existing clipboard content.

  1. GetClipboardItemCount
    • Retrieves and returns the number of items in the clipboard.

  1. SaveClipboardContent
    • Saves the current clipboard content for later restoration.

  1. RestoreClipboardContent
    • Restores the previously saved clipboard content.

  1. StartClipboardMonitoring
    • Starts monitoring clipboard changes and triggers an event on content change.

  1. StopClipboardMonitoring
    • Stops monitoring clipboard changes.

  1. ClipboardContentChanged
    • Event triggered when the clipboard content changes.

  1. ClearSavedClipboardContent
    • Clears the saved clipboard content.

  1. ConvertClipboardToPlainText
    • Converts the clipboard content to plain text and returns it.

  1. ConvertTextToClipboard
    • Parameter: String text
    • Converts the provided text to clipboard content and triggers an event.

  1. ClipboardContentConverted
    • Event triggered after converting text to clipboard content.

  1. GetClipboardTextAndHtml
    • Retrieves and returns both the text and HTML content of the clipboard as a list.

  1. SetClipboardContentWithLimit
    • Parameters: String text, int maxLength
    • Sets the provided text as the clipboard content, truncated to the specified maximum length.

  1. IsClipDataSupported
    • Checks and returns whether ClipData is supported on the device.

  • HandlePermissionResponse
    • Parameters: String permission, boolean granted
    • Handles the response to a permission request, indicating whether the permission was granted or not.

Example video:

aia project:
ClearClipboardTest.aia (22.7 KB)

Extension:
JoeDevClearClipboard.aix (12.7 KB)


Thanks.
3 Likes

Looks like a really good extension Joe, but the method ClearClipboard used to clear the clipboard will mean that it's never empty. ClearClipboardCompletely sounds better, I will try it.

Is it limited to specific Android versions?

1 Like

Tested and working, Android 10, single string. (APK)

1 Like

Yes, I was procrastinating for a few days because I couldn't completely delete the clipboard. I think there must be some way to do it, but I couldn't find it, I think you can do it.

I haven't tried it on other devices, but it should work on all of them, tested on Android 11.

Really crazy that Google have left an often used facility insecure.

As it is going, everything is restricting, it won't be long before it does. He is going to make it more difficult for us every time.

But we will find a way.

1 Like

Hi, can the clipboardContentChanged block still monitor the clipboard when my app is in the background - ie, is not the current app which might be making changes to the clipboard?
Thanks,
C.

Most probably not
You can try someone together with itoo Open Source • Background Tasks: Itoo 🚀

This is what Gemini thinks:

Creating a clipboard monitor for Target SDK 35 (Android 15) is a significant technical challenge because of strict privacy changes introduced by Google.

​Starting with Android 10, apps are strictly forbidden from reading the clipboard while in the background unless they are the "Default Input Method" (the keyboard). On Android 14 and 15, even if you have a Foreground Service, the system will show a visible notification or block access if the app does not have focus.

​However, you can achieve this if the user manually grants a "Special Permission" via ADB or if you use a Foreground Service to keep the listener alive.

  1. The App is in the Foreground: It will work perfectly as long as the user is looking at the app.
  2. The App is in the Background: The event will not fire by default. To bypass this, your users must run an ADB command on their phone to grant the hidden permission:

​adb shell appops set your.package.name READ_CLIPBOARD allow

Taifun