Intent.EXTRA_LOCAL_ONLY不工作 [英] Intent.EXTRA_LOCAL_ONLY doesnt work

查看:412
本文介绍了Intent.EXTRA_LOCAL_ONLY不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在我的应用程序做的是让用户选择从他的手机图库中的图片。在code我使用如下:

What I'm trying to do in my application is to let the user choose a picture from his phone's gallery. The code I'm using is as follows:

Intent intentBrowseFiles = new Intent();
    intentBrowseFiles.setType("image/*");
    intentBrowseFiles.setAction(Intent.ACTION_GET_CONTENT);
    intentBrowseFiles.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    startActivityForResult(Intent.createChooser(intentBrowseFiles,"Select Picture"), SHOW_GALLERY); 

通过将:

intentBrowseFiles.putExtra(Intent.EXTRA_LOCAL_ONLY, true); 

我觉得这只会火画廊意图,而是用户留下了他的车程,Dropbox和当地画廊以及其他在线帐户的选择...

I thought this would only fire the gallery intent, but instead user is left with the selection of his drive, dropbox and other online accounts along with the local gallery...

我不希望任何其他远程资源,有没有我缺少的东西在这里?

I don't want any other remote resources, is there something that I'm missing here?

推荐答案

当你使用像 ACTION_GET_CONTENT 意图的动作,你告诉系统选择哪些应用打开。如果用户还没有为它设置默认情况下,它会询问要使用的应用程序。在对话框中的应用程序将显示已表示,他们可以处理该类型的意图任何应用。

When you use an intent action like ACTION_GET_CONTENT, you're telling the system to choose which app to open. If the user hasn't set a default for it, it will ask which app to use. The apps in the dialog will show any apps that have said they can handle an intent of that type.

如果你想使用一个意图开始的具体的活动中,你必须通过名字来称呼它。这里的问题是,该库的应用程序可能被命名为不同在不同设备上,或者完全删除。

If you want to use an intent to start a specific activity, you have to call it by name. The problem here is that the gallery app may be named differently on different devices, or removed altogether.

允许用户选择自己所选择的应用程序是的一般的正确的事情。这绝对是Androidy的方式来做到这一点。

Allowing a user to choose their app of choice is generally the right thing to do. It's definitely the "Androidy" way to do it.

无论哪种方式, EXTRA_LOCAL_ONLY 只告诉接收应用程序,它的的唯一回报是present数据。它不强制执行的条件。

Either way, EXTRA_LOCAL_ONLY only tells the receiving app that it should return only data that is present. It doesn't enforce that condition.

这篇关于Intent.EXTRA_LOCAL_ONLY不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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