2013-05-31 80 views

回答

2

你有你的類聲明之前添加

[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); 
    } 
} 
+1

謝謝!這非常有幫助! – davidlebr1

+0

歡迎@ Dave.Lebr1 :) – Roosevelt

相關問題