Android:消息意图

发布于 2025-01-05 06:44:42 字数 248 浏览 3 评论 0原文

我是安卓初学者。我需要知道是否有打开创建消息窗口的意图。我尝试使用这段代码 -

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");

但是,它引发了,Gmail、电子邮件和;消息 我只需要提出消息。在我的应用程序中,当我按下按钮时,我必须集成它。有人能知道这个吗?指导我。

I'm a beginner to android. I need to know is there any intent to open the Create Message window. I tried with this code -

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");

But, it raises, Gmail, Email & Message I need to raise only message. In my application i've to integrate this when i press the button. Can anybody know this? Guide me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

So要识趣 2025-01-12 06:44:42

您可以在 xml 文件中添加

android:onClick = "onClick" 

并在活动中:

//main buttons listener
public void onClick(View view)
{
    switch (view.getId())
    {
            case R.id.sms:
            Intent intentsms = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + "" ) );
            intentsms.putExtra( "sms_body", "Test text..." );
            startActivity( intentsms );
            break;
    }
} 

You can just in your xml file add

android:onClick = "onClick" 

and in activity:

//main buttons listener
public void onClick(View view)
{
    switch (view.getId())
    {
            case R.id.sms:
            Intent intentsms = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + "" ) );
            intentsms.putExtra( "sms_body", "Test text..." );
            startActivity( intentsms );
            break;
    }
} 
波浪屿的海角声 2025-01-12 06:44:42

试试这个:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL  , new String[] { "[email protected]" });
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

Try this:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL  , new String[] { "[email protected]" });
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
大海や 2025-01-12 06:44:42

这将帮助您:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);

This will help you:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
灰色世界里的红玫瑰 2025-01-12 06:44:42

像这样使用所有应用程序都会接受这个意图

case R.id.action_shareapp:
            Intent send = new Intent(Intent.ACTION_SEND);
            send.setType("text/plain");
            send.putExtra(
                    Intent.EXTRA_TEXT,
                    "Checkout this coool App follow this link. https://play.google.com/store/apps/details?id=com.picknget.android");
            startActivity(Intent.createChooser(send, "Share with"));
            break;

Use just like this for all applications will accept this intent

case R.id.action_shareapp:
            Intent send = new Intent(Intent.ACTION_SEND);
            send.setType("text/plain");
            send.putExtra(
                    Intent.EXTRA_TEXT,
                    "Checkout this coool App follow this link. https://play.google.com/store/apps/details?id=com.picknget.android");
            startActivity(Intent.createChooser(send, "Share with"));
            break;
浅沫记忆 2025-01-12 06:44:42

我想这应该有效:

i.addCategory(Intent.CATEGORY_DEFAULT);
i.setType("vnd.android-dir/mms-sms");

I guess this should work:

i.addCategory(Intent.CATEGORY_DEFAULT);
i.setType("vnd.android-dir/mms-sms");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文