我想通過發送短信在兩個應用程序之間進行通信。 這是我第一個包含一個按鈕的應用程序,它將調用發送操作,以便所有其他具有操作SEND的應用程序出現在此對話框中。沒有應用程序來執行此acion - 對話框始終
((Button) findViewById(R.id.button1))
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra("ComingFrom", "Activity 1");
final int result = 1;
startActivityForResult(Intent.createChooser(intent, "Sending File..."),result);
}
});
現在這是我的第二個應用程序,將獲得意圖。
// Get the intent that started this activity
Intent intent = getIntent();
Uri data = intent.getData();
if (intent != null) {
// 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 ...
}
}
這是我的第二個應用程序清單,其中包含Action SEND。
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
<data android:mimeType="image/*" />
</intent-filter>
但問題是,我沒有得到一個對話框,顯示了我的其他應用卻顯示沒有應用程序來執行此操作。 我在做什麼錯?