本文介绍了如何添加您的应用程序的"分享"与MonoDroid的菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的解决方案是基于这篇文章:的
My solution is based on this article: http://twigstechtips.blogspot.com/2011/10/android-sharing-images-or-files-through.html
推荐答案
您必须添加
[IntentFilter(new[]{Intent.ActionSend},Categories = new[]{Intent.CategoryDefault},DataMimeType = "image/*",Label = "Your application name")]
您的类声明之前。
像这样的:
before your class declaration.Like this:
[Activity(Label = "Activity label", ScreenOrientation = ScreenOrientation.Portrait)]
[IntentFilter(new[]{Intent.ActionSend},Categories = new[]{Intent.CategoryDefault},DataMimeType = "image/*",Label = "Your application name")]
public class YourActivity: Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
if (Intent.Action == Intent.ActionSend && Intent.Extras.ContainsKey(Intent.ExtraStream))
{
var fileUrl = GetFilePath((Android.Net.Uri)Intent.Extras.GetParcelable(Intent.ExtraStream));
}
}
private string GetFilePath(Android.Net.Uri uri)
{
string[] proj = {MediaStore.Images.ImageColumns.Data};
var cursor = ManagedQuery(uri, proj, null, null, null);
var colIndex = cursor.GetColumnIndex(MediaStore.Images.ImageColumns.Data);
cursor.MoveToFirst();
return cursor.GetString(colIndex);
}
}
这篇关于如何添加您的应用程序的"分享"与MonoDroid的菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!