Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Message Intent

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.

like image 457
Galaxy S2 Avatar asked Feb 15 '12 09:02

Galaxy S2


People also ask

What is Intent message?

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.

What does Intent mean in Android?

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.

What is the use of Intent filter in Android?

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.


2 Answers

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;
    }
} 
like image 178
goodm Avatar answered Sep 20 '22 16:09

goodm


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();
}
like image 39
Nitesh Khosla Avatar answered Sep 21 '22 16:09

Nitesh Khosla