什么是当我有使用意图createChooser?我可以做这种方法吗? [英] What is createChooser when I have to use Intents? What I could do with this method?

查看:118
本文介绍了什么是当我有使用意图createChooser?我可以做这种方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑看看了计算器,但余did't找到一个关于什么是createChooser的定义,为什么我可以使用,并在whick种情况是很好的利用它。

I have been taking a look over stackoverflow but I did't find a definition about what is "createChooser" and why I can use and in whick kind of situations is good to use it.

在此先感谢。

推荐答案

例如:你在你的应用程序中共享图片选项

For example: you have a share picture option in your application.

您像这样定义一个意图:

You define an intent like this:

Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/jpeg");

File downloadedPic =  new File(
    Environment.getExternalStoragePublicDirectory(
    Environment.DIRECTORY_DOWNLOADS),
    "q.jpeg");

picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));

当你调用比:

startActivity(picMessageIntent);  

在手机上能够得到这幅画的所有应用程序将被列出。

all applications on your phone capable of getting this picture will be listed.

如果您想custimize该列表的标题,你可以使用createChooser这样的:

startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));

这篇关于什么是当我有使用意图createChooser?我可以做这种方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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