我想通过发送短信在两个应用程序之间进行通信。 这是我第一个包含一个按钮的应用程序,它将调用发送操作,以便所有其他具有操作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>
但问题是,我没有得到一个对话框,显示了我的其他应用却显示没有应用程序来执行此操作。 我在做什么错?