如何将消息从一个应用程序发送到另一个应用

时间:2017-06-15 00:26:48

标签: java android messaging

我只想知道如何:

  1. 指定将在" app chooser"中显示的应用选项意图活动(例如,只显示具有消息传递功能的应用程序)
  2. 如何从一个应用程序向另一个应用程序传输/显示消息(电子邮件,文本,DM等)?
  3. 甚至可能吗?我需要使用/研究哪些api / classes?我是否必须用另一种语言编写代码并将其转移?我目前正在使用java工作。

2 个答案:

答案 0 :(得分:1)

选项列表取决于您设置的Intenet类型。以下是您可能使用的意图类型 -

myIntent.setType(String mimeType)

image/jpeg
audio/mpeg4-generic
text/html
audio/mpeg
audio/aac
audio/wav
audio/ogg
audio/midi
audio/x-ms-wma
video/mp4
video/x-msvideo
video/x-ms-wmv
image/png
image/jpeg
image/gif
.xml ->text/xml
.txt -> text/plain
.cfg -> text/plain
.csv -> text/plain
.conf -> text/plain
.rc -> text/plain
.htm -> text/html
.html -> text/html
.pdf -> application/pdf
.apk -> application/vnd.android.package-archive

请参阅意向文档here

答案 1 :(得分:0)

我想也许这就是你要找的东西。

Send Simple Data to Other Apps

以下是文档中的示例。

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));