Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当有人长按链接并选择共享链接并选择我的应用程序时,它会抓取它并执行它的功能..但这也适用于其他可共享的文本项。我只想接受链接。目前我的 mime 类型为 text/plain。是否有链接的 MIME 类型?
不,对不起。至少对于标准的 Android 浏览器,它使用text/plain. 欢迎您检查发送给您的值,通过正则表达式查看它是否像 URL,并弹出错误指示您只发送链接。
text/plain
理论上,您甚至可以转身执行startActivity()相同Intent的操作,以允许用户选择其他内容来尝试共享。不过,我还没有尝试过,所以这里可能会有一些我不知道的小问题。
startActivity()
Intent