Android : Message Intent

2019-02-16 23:28发布

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.

5条回答
聊天终结者
2楼-- · 2019-02-16 23:40

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;
    }
} 
查看更多
Animai°情兽
3楼-- · 2019-02-16 23:40

Try this:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL  , new String[] { "recipient@example.com" });
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();
}
查看更多
一夜七次
4楼-- · 2019-02-16 23:47

I guess this should work:

i.addCategory(Intent.CATEGORY_DEFAULT);
i.setType("vnd.android-dir/mms-sms");
查看更多
倾城 Initia
5楼-- · 2019-02-16 23:53

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;
查看更多
迷人小祖宗
6楼-- · 2019-02-16 23:56

This will help you:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
查看更多
登录 后发表回答