Question

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.

Was it helpful?

Solution

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;
    }
} 

OTHER TIPS

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();
}

This will help you:

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

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;

I guess this should work:

i.addCategory(Intent.CATEGORY_DEFAULT);
i.setType("vnd.android-dir/mms-sms");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top