gpt4 book ai didi

android-intent - 如何使用 monodroid 将您的应用程序添加到 "Share"菜单

转载 作者:行者123 更新时间:2023-12-04 20:11:28 24 4
gpt4 key购买 nike

最佳答案

你必须添加

[IntentFilter(new[]{Intent.ActionSend},Categories = new[]{Intent.CategoryDefault},DataMimeType = "image/*",Label = "Your application name")]

在你的类声明之前。
像这样:
[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);
}
}

关于android-intent - 如何使用 monodroid 将您的应用程序添加到 "Share"菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16858881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com