Discussion:
Best way to launch Messaging app via intent
Steve
2010-01-13 10:21:14 UTC
Permalink
Hi. What is the recommended way to launch the messaging app (for
sending an MMS message) via an intent? The following code works on my
HTC Magic ...

Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("address", "0215555555");
intent.putExtra("sms_body", "my message text");
intent.putExtra(Intent.EXTRA_STREAM, imageUri); // imageUri set
previously
intent.setType("image/jpeg");
startActivity(intent);

... but it first launches the Resolver activity
(com.android.internal.app.ResolverActivity), prompting the user to
select the appropriate app (Email, Gmail, Messaging, Picasa). The
user has to select Messaging before proceeding.

The only way I've found to bypass the resolver is to explicity set the
desired component on the intent before starting the activity as
follows:

intent.setClassName("com.android.mms",
"com.android.mms.ui.ComposeMessageActivity");

However, I'm guessing this approach will not work on devices that have
a customised UI, like the HTC Hero. Can someone confirm/deny?

I'm also struggling to find official documentation for the "address"
and "sms_body" fields that can be supplied as extra data as per the
above example. Is it expected that these will be supported by the
default messaging app in future SDK versions and in customised UIs
(like HTC's Sense UI)?

Thanks in advance ...
Kumar Bibek
2010-01-13 10:45:28 UTC
Permalink
This is the expected behaviour. If you are using the implicit intent,
all the applications that accept this kind of data will be shown. You
cannot bypass this by using implicit intents.
Yes, explicit intents are the only solution for you.

But I would suggest to use implicit intent only. Since, the user
should have a choice as to which application should perform the
action.

"I'm also struggling to find official documentation for the "address"
and "sms_body" fields that can be supplied as extra data as per the
above example. Is it expected that these will be supported by the
default messaging app in future SDK versions and in customised UIs
(like HTC's Sense UI)? "

Somebody from Google or Mark can help you with the fields.

Kumar Bibek
http://tech-droid.blogspot.com
Hi.  What is the recommended way to launch the messaging app (for
sending an MMS message) via an intent? The following code works on my
HTC Magic ...
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra("address", "0215555555");
    intent.putExtra("sms_body", "my message text");
    intent.putExtra(Intent.EXTRA_STREAM, imageUri); // imageUri set
previously
    intent.setType("image/jpeg");
    startActivity(intent);
... but it first launches the Resolver activity
(com.android.internal.app.ResolverActivity), prompting the user to
select the appropriate app (Email, Gmail, Messaging, Picasa).  The
user has to select Messaging before proceeding.
The only way I've found to bypass the resolver is to explicity set the
desired component on the intent before starting the activity as
    intent.setClassName("com.android.mms",
"com.android.mms.ui.ComposeMessageActivity");
However, I'm guessing this approach will not work on devices that have
a customised UI, like the HTC Hero.  Can someone confirm/deny?
I'm also struggling to find official documentation for the "address"
and "sms_body" fields that can be supplied as extra data as per the
above example. Is it expected that these will be supported by the
default messaging app in future SDK versions and in customised UIs
(like HTC's Sense UI)?
Thanks in advance ...
Mark Murphy
2010-01-13 14:24:21 UTC
Permalink
Post by Steve
Hi. What is the recommended way to launch the messaging app (for
sending an MMS message) via an intent?
There is no way to launch specifically the Messaging app that is covered
in the SDK.
Post by Steve
The following code works on my
HTC Magic ...
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("address", "0215555555");
intent.putExtra("sms_body", "my message text");
intent.putExtra(Intent.EXTRA_STREAM, imageUri); // imageUri set
previously
intent.setType("image/jpeg");
startActivity(intent);
... but it first launches the Resolver activity
(com.android.internal.app.ResolverActivity), prompting the user to
select the appropriate app (Email, Gmail, Messaging, Picasa). The
user has to select Messaging before proceeding.
Precisely! After all, they might also choose another SMS client as well.
Post by Steve
The only way I've found to bypass the resolver is to explicity set the
desired component on the intent before starting the activity as
intent.setClassName("com.android.mms",
"com.android.mms.ui.ComposeMessageActivity");
However, I'm guessing this approach will not work on devices that have
a customised UI, like the HTC Hero. Can someone confirm/deny?
It is not part of the SDK and therefore is likely to break on select
devices or in future versions of Android. It also may not use the user's
preferred SMS client.
Post by Steve
I'm also struggling to find official documentation for the "address"
and "sms_body" fields that can be supplied as extra data as per the
above example.
They are not documented. The only documented extras for ACTION_SEND are
EXTRA_TEXT, EXTRA_STREAM, EXTRA_EMAIL, EXTRA_CC, EXTRA_BCC, and
EXTRA_SUBJECT (all public static data members on the Intent class).

http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND
Post by Steve
Is it expected that these will be supported by the
default messaging app in future SDK versions and in customised UIs
(like HTC's Sense UI)?
I would not expect that at all.

Either send the SMS yourself (via SmsManager) or don't assume SMS is the
desired messaging mechanism -- just offer an ACTION_SEND without an
address and let the user send whatever it is they want to whoever they
want however they want. Heck, for you know, the user would prefer to
post whatever it is on their Twitter account, which they can do via
ACTION_SEND if they have Twidroid installed (or other Twitter clients
that implement ACTION_SEND support, if any).
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android App Developer Training: http://commonsware.com/training
Steve
2010-01-13 19:26:17 UTC
Permalink
Thanks guys. Is it possible to send an MMS myself (via SmsManager)?

With the specific application I have in mind I have to send an MMS
(SMS or email will not work), and I need to default the message body,
attachment and address list (there could be multiple addressees). If
I can do this programatically and send the MMS myself then great. If
not, then launching a messaging client with appropriate defaults via
an intent is fine. If I go the latter route, ideally I would like to
specify in the intent that an MMS client should be invoked. The user
would only be prompted to choose an app if multiple MMS clients were
installed.

What would you suggest. Can either of the above approaches be safely
implemented using the current SDK?

Thanks again ...
Steve
Post by Mark Murphy
Either send the SMS yourself (via SmsManager) or don't assume SMS is the
desired messaging mechanism -- just offer an ACTION_SEND without an
address and let the user send whatever it is they want to whoever they
want however they want. Heck, for you know, the user would prefer to
post whatever it is on their Twitter account, which they can do via
ACTION_SEND if they have Twidroid installed (or other Twitter clients
that implement ACTION_SEND support, if any).
Dianne Hackborn
2010-01-13 20:22:36 UTC
Permalink
The stock SMS/MMS application handles the SENDTO action with an sms:,
smsto:, mms:, or mmsto: URI. I can't guarantee that devices shipping with a
custom MMS app will also handle these, though.
Post by Steve
Hi. What is the recommended way to launch the messaging app (for
sending an MMS message) via an intent? The following code works on my
HTC Magic ...
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("address", "0215555555");
intent.putExtra("sms_body", "my message text");
intent.putExtra(Intent.EXTRA_STREAM, imageUri); // imageUri set
previously
intent.setType("image/jpeg");
startActivity(intent);
... but it first launches the Resolver activity
(com.android.internal.app.ResolverActivity), prompting the user to
select the appropriate app (Email, Gmail, Messaging, Picasa). The
user has to select Messaging before proceeding.
The only way I've found to bypass the resolver is to explicity set the
desired component on the intent before starting the activity as
intent.setClassName("com.android.mms",
"com.android.mms.ui.ComposeMessageActivity");
However, I'm guessing this approach will not work on devices that have
a customised UI, like the HTC Hero. Can someone confirm/deny?
I'm also struggling to find official documentation for the "address"
and "sms_body" fields that can be supplied as extra data as per the
above example. Is it expected that these will be supported by the
default messaging app in future SDK versions and in customised UIs
(like HTC's Sense UI)?
Thanks in advance ...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
Dianne Hackborn
Android framework engineer
***@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.
Mark Murphy
2010-01-13 20:42:44 UTC
Permalink
Post by Dianne Hackborn
The stock SMS/MMS application handles the SENDTO action with an sms:,
smsto:, mms:, or mmsto: URI. I can't guarantee that devices shipping
with a custom MMS app will also handle these, though.
Hey, thanks for the info!

I've added an issue, requesting that this be added to the docs:

http://code.google.com/p/android/issues/detail?id=6027
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 2.8
Available!
Steve
2010-01-13 21:24:08 UTC
Permalink
Thanks for the info Dianne. When using the SENDTO action with an
mms: URI, can multiple addressees be supplied? If yes could you
please give an example?

Also, am I correct in concluding that there is currently no documented
API for programatically sending MMS? (SmsManager doesn't appear to
cover this.) Any plans to add this to an upcoming release?

Cheers
Steve
Post by Mark Murphy
Post by Dianne Hackborn
The stock SMS/MMS application handles the SENDTO action with an sms:,
smsto:, mms:, or mmsto: URI.  I can't guarantee that devices shipping
with a custom MMS app will also handle these, though.
Hey, thanks for the info!
http://code.google.com/p/android/issues/detail?id=6027
--
Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy
_The Busy Coder's Guide to Android Development_ Version 2.8
Available!
Dianne Hackborn
2010-01-14 00:57:54 UTC
Permalink
Sorry I don't know the details of this stuff.
Post by Steve
Thanks for the info Dianne. When using the SENDTO action with an
mms: URI, can multiple addressees be supplied? If yes could you
please give an example?
Also, am I correct in concluding that there is currently no documented
API for programatically sending MMS? (SmsManager doesn't appear to
cover this.) Any plans to add this to an upcoming release?
Cheers
Steve
Post by Mark Murphy
Post by Dianne Hackborn
The stock SMS/MMS application handles the SENDTO action with an sms:,
smsto:, mms:, or mmsto: URI. I can't guarantee that devices shipping
with a custom MMS app will also handle these, though.
Hey, thanks for the info!
http://code.google.com/p/android/issues/detail?id=6027
--
Mark Murphy (a Commons Guy)http://commonsware.com|
http://twitter.com/commonsguy
Post by Mark Murphy
_The Busy Coder's Guide to Android Development_ Version 2.8
Available!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
Dianne Hackborn
Android framework engineer
***@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.
d***@wivsys.com
2010-01-19 07:47:05 UTC
Permalink
When setting the action to ACTION_VIEW and type to "vnd.android-dir/
mms-sms" on the calling intent, multiple phone numbers can be passed
via the address attribute using a semi-colon delimited list:

http://andmobidev.blogspot.com/2010/01/launching-smsmessages-activity-using.html

Don't know if this will work in your situation.
Thanks for the info Dianne.    When using the SENDTO action with an
mms: URI, can multiple addressees be supplied?  If yes could you
please give an example?
Also, am I correct in concluding that there is currently no documented
API for programatically sending MMS?   (SmsManager doesn't appear to
cover this.)  Any plans to add this to an upcoming release?
Cheers
Steve
Post by Mark Murphy
Post by Dianne Hackborn
The stock SMS/MMS application handles the SENDTO action with an sms:,
smsto:, mms:, or mmsto: URI.  I can't guarantee that devices shipping
with a custom MMS app will also handle these, though.
Hey, thanks for the info!
http://code.google.com/p/android/issues/detail?id=6027
--
Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy
_The Busy Coder's Guide to Android Development_ Version 2.8
Available!
Steve
2010-01-19 20:54:53 UTC
Permalink
Post by d***@wivsys.com
When setting the action to ACTION_VIEW and type to "vnd.android-dir/
mms-sms" on the calling intent, multiple phone numbers can be passed
Yes, I am familiar with using the address attribute (set by
intent.putExtra) to specify one or more phone numbers. It's not
documented, however, so it's not guaranteed to work in the future.
That said, neither is the "body_text" attribute or the mms: / mmsto:
scheme documented either. I'll raise a request to get these added to
the API documentation and an additional intent filter created so that
there will be an officially documented way to send MMS, supplying
defaults for the addressee list, body text and attachment.

d***@wivsys.com
2010-01-19 07:30:38 UTC
Permalink
When setting the action to ACTION_VIEW and type to "vnd.android-dir/
mms-sms" on the calling intent, multiple phone numbers can be passed
via the address attribute using a semi-colon delimited list:

http://andmobidev.blogspot.com/2010/01/launching-smsmessages-activity-using.html

Don't know if this would work for your situation.
Thanks for the info Dianne.    When using the SENDTO action with an
mms: URI, can multiple addressees be supplied?  If yes could you
please give an example?
Also, am I correct in concluding that there is currently no documented
API for programatically sending MMS?   (SmsManager doesn't appear to
cover this.)  Any plans to add this to an upcoming release?
Cheers
Steve
Post by Mark Murphy
The stockSMS/MMS application handles the SENDTO action with ansms:,
smsto:, mms:, or mmsto: URI.  I can't guarantee that devices shipping
with a custom MMS app will also handle these, though.
Hey, thanks for the info!
http://code.google.com/p/android/issues/detail?id=6027
--
Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy
_The Busy Coder's Guide toAndroidDevelopment_ Version 2.8
Available!
Steve
2010-01-18 00:39:02 UTC
Permalink
Post by Dianne Hackborn
The stock SMS/MMS application handles the SENDTO action with an sms:,
smsto:, mms:, or mmsto: URI. I can't guarantee that devices shipping with a
custom MMS app will also handle these, though.
After experimenting with the SENDTO action and mms: URIs, I think an
extra
intent filter is needed in the stock SMS/MMS application.

Currently the ComposeMessageActivity intent filter for the SENDTO
action and "mms"
scheme is as follows:

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>

Notice that there is currently no provision for mimeType. This means
that I
can't specify the mimeType of the attachment in the intent when I try
to launch the
mms app via SENDTO. The result of this is that any image I specify
via
intent.putExtra(Intent.EXTRA_STREAM, imageUri) gets ignored. The
messing app opens
but with no attachment.

If I specify both the URI scheme ("mms") and the Mime Type ("image/
jpeg") via intent.setDataAndType()
with action SENDTO, the intent does not resolve to any activity.

It seems a bit pointless offering support for the "mms" scheme, but
providing no way to
provide an attachment. To fix this I suggest that a new intent filter
be added to
ComposeMessageActivity as follows:

<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
</intent-filter>

If that is a workable solution, any chance of including this in the
next release of the stock
SMS/MMS application?

Is there a more appropriate forum to make requests for Android
platform enhancements?

Cheers
Steve
Steve
2010-01-18 00:42:36 UTC
Permalink
Post by Dianne Hackborn
The stock SMS/MMS application handles the SENDTO action with an sms:,
smsto:, mms:, or mmsto: URI. I can't guarantee that devices shipping with a
custom MMS app will also handle these, though.
After experimenting with the SENDTO action and mms: URIs, I think an
extra intent filter is needed in the stock SMS/MMS application.

Currently the ComposeMessageActivity intent filter for the SENDTO
action and "mms" scheme is as follows:

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>

Notice that there is currently no provision for mimeType. This means
that I can't specify the mimeType of the attachment in the intent when
I try to launch the mms app via SENDTO. The result of this is that any
image I specify via intent.putExtra(Intent.EXTRA_STREAM, imageUri)
gets ignored. The messing app opens but with no attachment.

If I specify both the URI scheme ("mms") and the Mime Type ("image/
jpeg") via intent.setDataAndType() with action SENDTO, the intent does
not resolve to any activity.

It seems a bit pointless offering support for the "mms" scheme, but
providing no way to provide an attachment. To fix this I suggest that
a new intent filter be added to ComposeMessageActivity as follows:

<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
</intent-filter>

If that is a workable solution, any chance of including this in the
next release of the stock SMS/MMS application?

Is there a more appropriate forum to make requests for Android
platform enhancements?

Cheers
Steve
d***@wivsys.com
2010-01-19 08:06:26 UTC
Permalink
By setting the action to ACTION_VIEW and type to "vnd.android-dir/mms-
sms" on the calling intent, multiple phone numbers can be passed via
the address attribute using a semi-colon delimited list:

<a href="http://andmobidev.blogspot.com/2010/01/launching-smsmessages-
activity-using.html" target="_blank">http://andmobidev.blogspot.com/
2010/01/launching-smsmessages-activity-using.html</a>

Don't know if this will work for you.
Post by Steve
The stockSMS/MMS application handles the SENDTO action with ansms:,
smsto:, mms:, or mmsto: URI.  I can't guarantee that devices shipping with a
custom MMS app will also handle these, though.
After experimenting with the SENDTO action and mms: URIs, I think an
extra intent filter is needed in the stockSMS/MMS application.
Currently the ComposeMessageActivity intent filter for the SENDTO
<intent-filter>
<actionandroid:name="android.intent.action.VIEW" />
<actionandroid:name="android.intent.action.SENDTO" />
<categoryandroid:name="android.intent.category.DEFAULT" />
<categoryandroid:name="android.intent.category.BROWSABLE" />
<dataandroid:scheme="mms" />
<dataandroid:scheme="mmsto" />
</intent-filter>
Notice that there is currently no provision for mimeType.  This means
that I can't specify the mimeType of the attachment in the intent when
I try to launch the mms app via SENDTO. The result of this is that any
image I specify via intent.putExtra(Intent.EXTRA_STREAM, imageUri)
gets ignored.  The messing app opens but with no attachment.
If I specify both the URI scheme ("mms") and the Mime Type ("image/
jpeg") via intent.setDataAndType() with action SENDTO, the intent does
not resolve to anyactivity.
It seems a bit pointless offering support for the "mms" scheme, but
providing no way to provide an attachment.  To fix this I suggest that
<intent-filter>
<actionandroid:name="android.intent.action.SENDTO" />
<categoryandroid:name="android.intent.category.DEFAULT" />
<dataandroid:scheme="mms" />
<dataandroid:scheme="mmsto" />
<dataandroid:mimeType="image/*" />
<dataandroid:mimeType="video/*" />
<dataandroid:mimeType="audio/*" />
</intent-filter>
If that is a workable solution, any chance of including this in the
next release of the stockSMS/MMS application?
Is there a more appropriate forum to make requests forAndroid
platform enhancements?
Cheers
Steve
jotobjects
2010-01-19 19:44:22 UTC
Permalink
Post by Steve
Is there a more appropriate forum to make requests for Android
platform enhancements?
Yes, add a feature request here -

http://code.google.com/p/android/issues/entry?template=Developer%20defect%20report

Bear in mind the followup might not be what you want - for instance
the reply might be a description of why the feature is not possible or
not high priority, etc.
Loading...