Android : Message Intent
Asked Answered
P

5

7

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.

Preprandial answered 15/2, 2012 at 9:24 Comment(0)
A
9

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;
    }
} 
Absolutely answered 15/2, 2012 at 9:29 Comment(2)
If you can just up my answer :)Absolutely
I can't accept now. It's telling me to "You can only accept this answer within 3 minutes.Preprandial
T
4

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();
}
Thickleaf answered 15/2, 2012 at 9:34 Comment(0)
A
1

This will help you:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
Algin answered 15/2, 2012 at 9:32 Comment(0)
S
1

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;
Silvasilvain answered 18/10, 2014 at 5:27 Comment(1)
This solution doesn't copy text to FacebookForetooth
A
0

I guess this should work:

i.addCategory(Intent.CATEGORY_DEFAULT);
i.setType("vnd.android-dir/mms-sms");
Akkerman answered 15/2, 2012 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.