2016-09-20 3 views
-3

私の単純なandoroidアプリケーションは内部の電子メール送信者になることができます。私は他のアプリケーションで使用するためにマニフェストのアクティビティにいくつかのインテントフィルタを設定しようとしていますが、この能力を持つためにインテントフィルタを設定するにはどうすればいいですか?私は、ユーザーが私のアプリケーションを選択してメールを送信できるようにしたい、このコードを見つけましたが、それは正しくないようです。メールを送信するためにAndroidのインテントフィルタをマニフェストに設定する

<intent-filter android:label="Send Mail" android:icon="@drawable/pig"> 
    <data android:mimeType="text/plain"/> 
    <action android:name="android.intent.action.SEND"/> 
    <action android:name="android.intent.action.VIEW"/> 
    <category android:name="android.intent.category.DEFAULT"/> 
</intent-filter> 

答えて

-1

それは罰金&すべてがで定義されている作品Official Documentation

かかわら行く詳細情報については、あなたの活動のマニフェスト

<activity android:name="ShareActivity"> 
    <!-- filter for sending text; accepts SENDTO action with sms URI schemes --> 
    <intent-filter> 
     <action android:name="android.intent.action.SENDTO"/> 
     <category android:name="android.intent.category.DEFAULT"/> 
     <data android:scheme="sms" /> 
     <data android:scheme="smsto" /> 
    </intent-filter> 
    <!-- filter for sending text or images; accepts SEND action and text or image data --> 
    <intent-filter> 
     <action android:name="android.intent.action.SEND"/> 
     <category android:name="android.intent.category.DEFAULT"/> 
     <data android:mimeType="image/*"/> 
     <data android:mimeType="text/plain"/> 
    </intent-filter> 
</activity> 

ハンドル結果に

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.main); 

    // Get the intent that started this activity 
    Intent intent = getIntent(); 
    Uri data = intent.getData(); 

    // Figure out what to do based on the intent type 
    if (intent.getType().indexOf("image/") != -1) { 
     // Handle intents with image data ... 
    } else if (intent.getType().equals("text/plain")) { 
     // Handle intents with text ... 
    } 
} 

をインテントフィルタを定義します。詳細。

+0

''はメールに使用できますか? –

+0

SMSを送信するためのものはありませんが、実際にはこの操作を共有のために使用しています。要件に応じてこの部分を除外することができます。 –

関連する問題