有意图地启动短信应用程序 [英] launch sms application with an intent

查看:19
本文介绍了有意图地启动短信应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于意图的问题...我尝试启动短信应用...

I have a question about an intent... I try to launch the sms app...

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setType("vnd.android-dir/mms-sms");
int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP |
    Intent.FLAG_ACTIVITY_CLEAR_TOP;
intent.setFlags(flags);
intent.setData(Uri.parse("content://sms/inbox"));
context.startActivity(intent);

所以,你可以看到我把太多东西放在了我的意图中,但那是因为我不知道我该怎么做......谢谢

so, you can see that I put too much things in my intent, but that's because I don't know how I can do... Thank's

推荐答案

要开始启动 sms 活动,您只需要:

To start launch the sms activity all you need is this:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);         
sendIntent.setData(Uri.parse("sms:"));

您可以添加额外内容来填充您自己的消息等

You can add extras to populate your own message and such like this

sendIntent.putExtra("sms_body", x); 

然后就开始有意图的活动.

then just startActivity with the intent.

startActivity(sendIntent);

这篇关于有意图地启动短信应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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