Android发送彩信
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, uri);//uri为你的附件的uri
intent.putExtra("subject", subString);
//intent.putExtra("sms_body", "sdfsdf");
intent.putExtra(Intent.EXTRA_TEXT, "sdfsdf");
intent.setType("image/*");//彩信附件类型
intent.setClassName("com.android.mms",
"poseMessageActivity");
startActivity(intent);
接受彩信:
接受彩信只能提供一个思路。
通过BroadcastReceiver来拦截彩信接收信息,需要添加权限<uses-permission android:name="android.permission.RECEIVE_MMS"></uses-permission>追问恩,那如果添加多张图片呢?在android2.1以上只能发送一个附件,图片如果多张的话需要一幻灯片得方式发送,这样,又应该怎么设计呢?
回答String imagePath1 = "/sdcard/image1.png";
String imagePath2 = "/sdcard/image2.png";
Uri uri1 = Uri.parse("file://" + imagePath1);
Uri uri2 = Uri.parse("file://" + imagePath2);
ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(uri1);
uris.add(uri2);
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, uris);
//intent.putExtra("sms_body", "sdfsdf");
intent.putExtra(Intent.EXTRA_TEXT, "sdfsdf");
intent.setType("image/*");
intent.setClassName("com.android.mms",
"poseMessageActivity");
startActivity(intent);
改成这样,以幻灯片的形式发送
追问很感谢你.....
可以读取内存卡中的文件作为文本内容么?
比如在sdcard中有一个bhsj.txt文件,发送的时候,直接读取bhsj.txt文件的内容作为彩信内容发送,能来一点提示么?谢谢了
回答StringBuilder sBuilder = new StringBuilder();
try {
//读取文本文件
FileInputStream iStream = new FileInputStream("/sdcard/bhsj.txt");
byte[] buffer = new byte[1024];
int length = 0;
int totalLen = 0;
while ((length = iStream.read(buffer)) > 0) {
//将读取的文字保存的到StringBuidler
sBuilder.append(new String(buffer));
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//获得总的文本内容,这里如果是中文,可能有乱码,这个自己解决,不然代码就多了
String content = sBuilder.toString();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("LeMei", "feixun");
intent.putExtra(Intent.EXTRA_STREAM, uri);//uri为附件uri,这里要自己获取
//设置信息
intent.putExtra("sms_body", content);
intent.setType("image/*");
intent.setClassName("com.android.mms",
"poseMessageActivity");
startActivity(intent);。