问题描述
我要寻找的相当长一段时间的解决方案,我感到沮丧越来越多。
I am looking for a solution for quite a while and I am getting frustrated more and more.
我想我的应用程序能为其他应用程序提供内容。例如:当用Googlemail电子邮件应用程序,你可以添加附件。将打开一个对话框显示,可以为附件的文件中的所有应用程序。我的应用程序是在对话框中已经,因为我定义的一个活动,意图过滤器是这样的:
I want my app to be able to provide content for other apps. For example: When using GoogleMail app you can add an attachment. A dialog will be opened showing all apps that can provide an file for the attachment. My app is in the dialog already, because I defined an activity with an intent-filter like this:
<intent-filter >
<action android:name="android.intent.action.GET_CONTENT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="image/*" />
</intent-filter>
所以,当你拿起我的应用程序,它已经开始活动。活性允许用户选择照片,并将其写入到SD卡。到目前为止,一切都很好。但是,我怎么正确地返回了吗?由于附件Googlemail电子邮件永远不会做。我回国是这样说的:
So when you pick my app, it is starting the activity. The activity allows the user to select a photo and writes it to SD-card. So far so good.But how do I return it correctly? Because the attachment in GoogleMail is never made.I am returning it this way:
if(file!=null)
{
Intent resultIntent=new Intent();
resultIntent.setType("image/jpg");
Uri uri=Uri.fromFile(file);
//uri=Uri.parse(uri.toString().replace("file", "content"));
resultIntent.putExtra(Intent.EXTRA_STREAM, uri);
resultIntent.putExtra(Intent.EXTRA_UID, uri);
resultIntent.setData(uri);
setResult(RESULT_OK, resultIntent);
finish();
}
我是那么那么那么那么的高兴,如果有人可以帮助我。我相信这是一个简单的事情我做错了,但我不能找到任何可以帮助我。 :(
I would be so so so so happy if anybody could help me. I believe it is a simple thing I am doing wrong, but I can't find anything that helps me. :(
最好的问候
推荐答案
您可能会需要实现一个流供应商。真的没有什么好导游在那里,但这个一>是最接近我能找到。
You'll probably need to implement a stream provider. There really isn't any good guide out there, but this is the closest I could find.
这篇关于试图为应用程序调用GET_CONTET意图的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!