2016-12-28 5 views
2

このアプリケーションでは、ユーザーが任意の写真アプリケーションから画像を選択して共有するたびに、アプリケーションを共有アプリケーションのリストに表示することができます。 これは私がこの暗黙のアクションインテントを処理するためのものです。Xamarin Androidがactionsend MIMEタイプの暗黙のインテントを処理する

[IntentFilter(new string[] { Intent.ActionView }, 
Categories = new string[] { Intent.ActionDefault, Intent.CategoryBrowsable, 
Intent.ActionSend, Intent.ActionSendMultiple }, 
DataScheme = "mimetype", 
DataPathPattern = "*/*", 
DataHost = "*.*")] 

これは私が見つけたものである。このイメージまたは画像を処理するために、ここで

Intent intent = Intent; 

String action = intent.Action; 

String type = intent.Type; 

if (Intent.ActionSend.Equals(action) && type != null) 
{ 

    if (type.StartsWith("image/")) 
    { 
      tv.Text = "single image sharable"; 
      //handleSendImage(intent); // Handle single image being sent 

    } 

} 
else if (Intent.ActionSendMultiple.Equals(action) && type != null) 
{ 

    if (type.StartsWith("image/")) 
    { 
     tv.Text = "multiple images sharable"; 
     //handleSendMultipleImages(intent); // Handle multiple images being sent 
    } 
} 

は、今私はギャラリーから画像を共有しようが、私は、リスト内の自分のアプリケーションが表示されません。 インテントフィルタで何かが間違っていなければなりません。単一または複数の画像を共有するための

+1

記載されているインテントフィルタに、間違ったカテゴリが含まれています。 "Categories = new string [] {Intent.ActionDefault}"の代わりに、代わりにIntent.CategoryDe​​faultにする必要があります。 – kg743

答えて

2

IntentFilter例:

[IntentFilter(
    new string[] { Intent.ActionSend }, 
    Categories = new string[] { Intent.CategoryDefault }, 
    DataMimeType = "image/*" 
)] 
[IntentFilter(
    new string[] { Intent.ActionSendMultiple }, 
    Categories = new string[] { Intent.CategoryDefault }, 
    DataMimeType = "image/*" 
)] 
[Activity(Label = "Share data to this activity", MainLauncher = true, Icon = "@mipmap/icon")] 
public class MainActivity : Activity 
{ 
    protected override void OnCreate(Bundle savedInstanceState) 
    { 
     base.OnCreate(savedInstanceState); 

     if (Intent.Action == Intent.ActionSend) 
     { 
      Log.Debug("Share", Intent.Type); 
     } 
     else if (Intent.Action == Intent.ActionSendMultiple) 
     { 
      Log.Debug("Share", Intent.Type); 
     } 
    } 
} 

:クラスベースAndroidManifestAttributesを使用している場合、私は非常にあなたが生成されることを保証するためにDebug|Releaseディレクトリ内に生成されたAndroidManifest.xmlの見直しをお勧めします正しいエントリ。

YourAndroidProjectDirectory/Debug/android/manifest/AndroidManifest.xml 
関連する問題