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.
An intent is to perform an action on the screen. It is mostly used to start activity, send broadcast receiver,start services and send message between two activities. There are two intents available in android as Implicit Intents and Explicit Intents.
An Intent is a messaging object you can use to request an action from another app component. Although intents facilitate communication between components in several ways, there are three fundamental use cases: Starting an activity. An Activity represents a single screen in an app.
An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.
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;
}
}
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With