对于ACTION_SEND文字理智设置默认的应用程序(通过选配,preference等) [英] Sensibly setting default app (through Chooser, Preference, etc.) for ACTION_SEND text
问题描述
我的应用程序将是(可选)当执行一个动作发送社交媒体更新。
我想通过使用用户安装社交媒体应用程序来做到这一点。我不想限制用户对任何特定的一组应用程序,所以任何可以与类型文本到
将被罚款。 ACTION_SEND
意图做出回应/平原
不过,我不希望用户必须选择每一次 - 通常情况下,他们会使用相同的应用程序每一次,也就是说,一旦他们拿起TweetCaster / Facebook的/不管,他们会坚持吧。
如果我只是 startActivity()
与 ACTION_SEND
和文本/纯
,我得到一个完整的动作使用选配了,也有一个默认情况下使用此操作复选框。
不过,这将设置该意图的所有应用程序的默认,而且似乎(一)可能是有人可能已经默认为一个非社交媒体应用发送文字,和(b),即使它们没有,似乎有点粗鲁默认这样一个通用的意图是什么地方发送一些文字。
什么是一般人吗?我中途做一个列表preference,允许特定应用程序的选择得到了(这样我就可以关火意图在一个应用程序,是preferred为的我的的应用程序,而不是系统范围) ,但它似乎想了很多code的东西这么简单。
我缺少的东西更明显?是否有点火了选择器,使在默认情况下为这次行动使用的方法将只用作默认操作的我的的应用ACTION_SENDing text / plain的?
有发射了选配,这样的默认情况下,这个动作用的一种方式,只会被用来作为我的应用程序ACTION_SENDing文字的默认操作/平?
块引用>没有,对不起。这是原因之一,为什么大部分的
ACTION_SEND
样本显示了使用Intent.createChooser()
,以消除使这个默认复选框,并忽略任何全系统默认的用户可能已经设置。而不是去
目录preference
的路线,你可以创建自己的选择器AlertDialog
(或对话为主题的活动
)用自己的默认的逻辑。这种默认可以是:
- 的特定选择,以及全系统的线让这个默认的
- 基于行为(例如,将您的列表变成经常使用的和其他选项)
- 基于别的东西(所有用户之间的聚合行为,月相,等等。)
创建超级选择器,他们拥有这种功能是我的一个中档痒,我很可能会划伤今年的某个时候,如果没人打我吧。
My application will be (optionally) sending social media updates when an action is performed.
I want to do this by using the user's installed social media apps. I don't want to restrict the user to any particular set of apps, so anything that can respond to an
ACTION_SEND
Intent with a type oftext/plain
will be fine.However, I don't want the user to have to choose every time -- typically, they'll by using the same app every time, i.e. once they've picked TweetCaster/Facebook/whatever, they'll be sticking with it.
If I just
startActivity()
withACTION_SEND
andtext/plain
, I get a "Complete action using" chooser up, and there's also a "Use by default for this action" checkbox.But, this will set the default for that intent for all applications, and it seems (a) likely that someone might already have defaulted to a non-social-media-app for sending text, and (b) even if they haven't, it seems a bit "rude" to default such a generic intent as sending some text somewhere.
What do people generally do here? I got halfway through making a ListPreference that allows the choice of a particular application (so I can just fire off the intent at an app that's preferred for my app, not systemwide), but it seems like a lot of code for something so simple.
Am I missing something more obvious? Is there a way of firing up the chooser such that the "Use by default for this action" will only be used as the default action for my app ACTION_SENDing text/plain?
解决方案Is there a way of firing up the chooser such that the "Use by default for this action" will only be used as the default action for my app ACTION_SENDing text/plain?
No, sorry. That's one reason why most of the
ACTION_SEND
samples show usingIntent.createChooser()
, to eliminate the "make this the default" checkbox and ignore any system-wide default the user may have set.Rather than go the
ListPreference
route, you could create your own chooserAlertDialog
(or dialog-themedActivity
) with your own "default" logic. That "default" could be:
- a specific selection, along the lines of the system-wide "make this the default"
- based on behavior (e.g., divide your list into "Frequently Used" and "Other" options)
- based on something else (aggregate behavior among all your users, phase of the moon, etc.)
Creating a "super chooser" that has this sort of functionality is a medium-grade itch of mine that I will likely scratch sometime this year if nobody beats me to it.
这篇关于对于ACTION_SEND文字理智设置默认的应用程序(通过选配,preference等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!