Android中常用的Intent启动服务

一些在 Android中常用的 Intent启动服务,当执行startActivity时候,Android将会根据Intent绑定的信息寻找最合适的启动程序来接应,并执行程序以完成意图的实现。

打开浏览器显示网页:
  1. Uriuri = Uri.parse("http://www.ataaw.com");
  2. Intent intent = new Intent(Intent.ACTION_VIEW,uri);
  3. startActivintenty(intent);
复制代码
地图参数显示地图:
  1. Uri uri = Uri.parse("geo:38.899533,-77.036476");
  2. Intent intent = new Intent(Intent.Action_VIEW,uri);
  3. startActivintenty(intent);
复制代码
拨打电话,调用拨号程序:
  1. Uri uri = Uri.parse("tel:13800138000");
  2. Intent intent = new Intent(Intent.ACTION_DIAL, uri);
  3. startActivintenty(intent);
复制代码
调用发送短信的程序发送SMS/MMS
  1. Intent intent = new Intent(Intent.ACTION_VIEW);
  2. intent.putExtra("sms_body", "ATAAW.COM");
  3. intent.setType("vnd.android-dir/mms-sms");
  4. startActivintenty(intent);
复制代码
调用短信程序发送短信
  1. Uri uri = Uri.parse("smsto:13800138000");
  2. Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
  3. intent.putExtra("sms_body", "ATAAW.COM");
  4. startActivintenty(intent);
复制代码
调用彩信服务发送彩信
  1. Uri uri = Uri.parse("content://media/external/images/media/exp");
  2. Intent intent = new Intent(Intent.ACTION_SEND);
  3. intent.putExtra("sms_body", "ATAAW.COM");
  4. intent.putExtra(Intent.EXTRA_STREAM, uri);
  5. intent.setType("image/png");
  6. startActivintenty(intent);
复制代码
启动邮件应用程序发送Email
  1. Uri uri = Uri.parse("mailto:ataaw.com@gmail.com");
  2. Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
  3. startActivintenty(intent);

  4. Intent intent = new Intent(Intent.ACTION_SEND);
  5. intent.putExtra(Intent.EXTRA_EMAIL, "android.sz@live.com");
  6. intent.putExtra(Intent.EXTRA_TEXT, "邮件内容。");
  7. intent.setType("text/plain");
  8. startActivintenty(Intent.createChooser(intent, "Choose Email Client"));

  9. Intent intent=new Intent(Intent.ACTION_SEND);
  10. String[] tos={"ataaw.com@gmail.com"};
  11. String[] ccs={"cc@ataaw.com"};
  12. intent.putExtra(Intent.EXTRA_EMAIL, tos);
  13. intent.putExtra(Intent.EXTRA_CC, ccs);
  14. intent.putExtra(Intent.EXTRA_TEXT, "邮件内容。");
  15. intent.putExtra(Intent.EXTRA_SUBJECT, "邮件主题");
  16. intent.setType("message/rfc822");
  17. startActivintenty(Intent.createChooser(intent, "Choose Email Client"));
复制代码
添加邮件附件内容
  1. Intent intent = new Intent(Intent.ACTION_SEND);
  2. intent.putExtra(Intent.EXTRA_SUBJECT, "主题");
  3. intent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/ataaw.mp3");
  4. sendIntent.setType("audio/mp3");
  5. startActivintenty(Intent.createChooser(intent, "Choose Email Client"));
复制代码
播放mp4多媒体文件
  1. Intent intent = new Intent(Intent.ACTION_VIEW);
  2. Uri uri = Uri.parse("file:///sdcard/ataaw.mp3");
  3. intent.setDataAndType(uri, "audio/mp3");
  4. startActivintenty(intent);
复制代码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值