发送短信意图的Andr​​oid [英] send SMS Intent in Android

查看:211
本文介绍了发送短信意图的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 字符串x =Hello World的;
字符串Y =你摇滚!;
意图sendIntent =新的意图(Intent.ACTION_VIEW);
sendIntent.putExtra(sms_body,x)的;
sendIntent.putExtra(sms_body,Y);
sendIntent.setType(vnd.android-DI​​R / MMS,SMS);
startActivity(sendIntent);
 

我想通过短信发送多消息体,但只有你摇滚!被显示。我想要做的是能够显示多条消息,并让它pre格式(在不同的线路)。

因此​​,例如......

 的Hello World
你摇滚!
 

解决方案

如果您想发送一个多行信息只是把一个换行符2串之间。

  X +\ N+ Y
 

如果要发送多封邮件是没有办法做到这一点,我是知道的。你可以使用[startActivityForResult] [1],然后在你的活动[onActivityResult] [2]的方法,您可以发送再下一条消息。

[1]:<一href="http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent" rel="nofollow">http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, INT)

[2]: 的http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, INT,android.content.Intent)

String x="Hello World";
String y="You Rock!!!";
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", x); 
sendIntent.putExtra("sms_body", y); 
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);

I'm trying to send a multiple message bodies via SMS, but only "You Rock!!!" is displayed. What i want to do is be able to display multiple messages and have it pre-formatted (on different lines).

So for example...

Hello World
You Rock!!!

解决方案

If you want to send a multi-line message just put a newline between the 2 strings.

x + "\n" + y

if want to send multiple messages there is no way to do that, that I am aware of. You could use [startActivityForResult][1] then in your activities [onActivityResult][2] method you can send then next message.

[1]:http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)

[2]: http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)

这篇关于发送短信意图的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆