Android系统中发送短信和彩信的源码

开发过程,将开发过程常用的内容段做个珍藏,如下资料是关于Android系统中发送短信和彩信的的内容,应该是对各位有较大用处。

String body="this is sms demo";

Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", number, null));

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true);

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true);

startActivity(mmsintent);

发送彩信:

StringBuilder sb = new StringBuilder();

sb.append(fd.getAbsoluteFile());

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null));

intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString());

intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent);

startActivity(intent);

你可能感兴趣的:(Android系统中发送短信和彩信的源码)