我一直在查看 stackoverflow,但我没有找到关于什么是“createChooser”的定义以及为什么我可以使用它以及在哪种情况下最好使用它。
提前致谢。
例如:您的应用程序中有一个共享图片选项。
您定义这样的意图:
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);
将列出您手机上能够获取此图片的所有应用程序。
如果您想自定义该列表的标题,可以使用 createChooser,如下所示:
startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)