android 发送短信,彩信,邮件代码

1:发送短信

            String body=”this is mms 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);


2:发送彩信

           StringBuilder sb = new StringBuilder();
            sb.append(”file://”);
            sb.append(fd.getAbsoluteFile());
            Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(”mmsto”, number, null));
            // Below extra datas are all optional.
            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);


3:发送Mail

             mime = “img/jpg”;
            shareIntent.setDataAndType(Uri.fromFile(fd), mime);
            shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fd));
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
            shareIntent.putExtra(Intent.EXTRA_TEXT, body);

 

转帖:http://hi.baidu.com/jiang_yy_jiang/blog/item/72191b00b7efa002738b6543.html

--------------------------------------------------------------------------------------------------------------------------------

windows上用eclipse开发和 使用unix环境开发是不一样的,windows上使用下面的就可以发送了,注意自己修改下。
Intent intent = new Intent(Intent.ACTION_SEND);           
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);          
            intent.putExtra("address", phnumber);
            intent.putExtra("compose_mode", false);
        intent.putExtra("exit_on_sent", true);
        intent.putExtra("subject", "彩信测试");
        intent.putExtra("sms_body", "this is mms send auto ");
        intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/ima.jpg"));
        intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
            intent.setType("image/jpeg");
           
            startActivity(Intent.createChooser(intent,"Send MMS To"));

 

转帖:http://www.eoeandroid.com/thread-21150-1-1.html

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

发送邮件的时候:no application can perform this action 或者 没有应用程序可执行此操作,

如下代码可解决:

String mailId=(String)ContactUs.this.getString(R.string.contactus8); 
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( 
"mailto",mailId, null)); 
//emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailId}); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body); 
startActivity(emailIntent); 

转贴:  http://www.coderanch.com/t/520651/Android/Mobile/no-application-perform-action-when

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值