Android 浏览器分享到APP「建议收藏」

Android 浏览器分享到APP「建议收藏」1 在配置文件添加权限 2 在配置文件中给分享到 APP 的界面 Acticiy 添加 intent filter 3 在跳转的 Activity 中来获取 Intent intent getIntent Bundle extras intent getExtras String action intent

1.在配置文件添加权限

2.在配置文件中给分享到APP的界面(Acticiy)添加intent-filter












3.在跳转的Activity中来获取

Intent intent = getIntent();
Bundle extras = intent.getExtras();
String action = intent.getAction();

if (Intent.ACTION_SEND.equals(action)) {
String content = (String) extras.getCharSequence(Intent.EXTRA_TEXT);
if (content != null) {
Log.e("AAA", "onCreate1: " + content);
CharSequence title = extras.getCharSequence(Intent.EXTRA_SUBJECT);
if (title == null)
title = content.substring(0,content.indexOf("http"));
Log.e("AAA", "onCreate2: " + title);
}
Uri uri = extras.getParcelable(Intent.EXTRA_STREAM);
if (uri != null){
Log.e("AAA", "onCreate3: " + uri.toString());
}
}
编程小号
上一篇 2025-02-16 21:40
下一篇 2025-02-18 10:11

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/117911.html