Android:以编程方式从剪贴板删除单个项目 [英] Android: Delete single item from clipboard programmatically

查看:159
本文介绍了Android:以编程方式从剪贴板删除单个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Clipboard-Service允许您仅将文本或其他项目添加到剪贴板,在大多数Android设备上,Clipdata项目将被插入到堆栈中,其中内容的最大数量未定义。我的问题如下:我有一个密码管理器应用程序,可以将选定的密码插入剪贴板,但是由于密码是高度敏感的数据,因此我希望在定义的超时时间过去后删除插入的密码。所以我的问题是:是否可以以某种方式对剪贴板条目进行高级访问并以某种方式对其进行修改?我知道该框架本身不允许这样做,但是有没有办法做到这一点?

The Android Clipboard-Service allows you just to add text or other items into the clipboard, where on most Android devices the Clipdata items will be inserted into a stack with undefined max number of content. My problem is the following: I have a password manager app which can insert a chosen password into the clipboard but because passwords are highly sensitive data I would like to remove an inserted password after the defined timeout has passed. So my question is the following: Is it somehow possible to get an advanced access to the Clipboard entries and modify it somehow? I know that the framework itself does not allow that but is there a hacky way to do it?

推荐答案


Clipdata项将被插入到未定义最大内容数的堆栈中。

the Clipdata items will be inserted into a stack with undefined max number of content

堆栈的大小为1。是每个用户一个系统剪贴板条目。参见例如实现剪贴板的Android 8.1系统服务。每个 PerUserClipboard 都保存一个 ClipData ,而不是一个堆栈。

The "stack" is of size 1. There is one system clipboard entry per user. See, for example, the Android 8.1 system service that implements the clipboard. Each PerUserClipboard holds a single ClipData, not a stack.

第三方应用程序可能提供某种剪贴板扩展程序,并且设备制造商或自定义ROM开发人员可能会修改Android处理剪贴板的方式。但是,这些超出了操作系统本身的范围。

It is possible that third-party apps offer some sort of clipboard extender, and it is possible that device manufacturers or custom ROM developers might modify how Android handles the clipboard. However, those go beyond the scope of the OS itself.


是否有可能以某种方式获得对剪贴板条目的高级访问权并对其进行修改

Is it somehow possible to get an advanced access to the Clipboard entries and modify it somehow?

您需要询问开发人员提供此扩展剪贴板功能的功能。

You would need to ask the developer of whatever is offering this extended clipboard capability. Perhaps they have an API that you can use.

您可以使用 ClipboardManager 设置当前剪贴板条目;在Android 9.0+上,您也可以使用 ClipboardManager 清除当前剪贴板条目。两者都会影响当前用户...但是仅适用于单项系统剪贴板。

You can set the current clipboard entry using ClipboardManager; on Android 9.0+, you can clear the current clipboard entry using ClipboardManager as well. Both will affect the current user... but only for the single-entry system clipboard.

这篇关于Android:以编程方式从剪贴板删除单个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆