Android 共享意图选择器 [英] Android share intent chooser

查看:29
本文介绍了Android 共享意图选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用类似的东西来使用用户手机上的可用应用程序共享一些文本.

I am using something like this to share some text using available applications on the user's phone.

public void share(String subject,String text) {
     final Intent intent = new Intent(Intent.ACTION_SEND);

     intent.setType("text/plain");
     intent.putExtra(Intent.EXTRA_SUBJECT, subject);
     intent.putExtra(Intent.EXTRA_TEXT, text);

     startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

我的主要问题是,如果用户选择 Twitter 而不是电子邮件,我想要一个不同的文本(例如,带有短 URL 的简短版本 VS 带有附加图像的全文).

My main problem is that I would like to have a different text if the user chooses Twitter instead of email for example (short version with short URLs VS full text with attached images).

如何不知道用户决定使用哪个应用程序?

How can ont find out which application the user has decided to use?

推荐答案

一旦您将文本交给系统,而 createChooser 不在您手中,此后就无法更改文本.

Once you hand the text off to the system with createChooser its out of your hands, no way to change the text after that.

这篇关于Android 共享意图选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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