Send Intent on Real Device

Search for BETA-testers and/or promote your own Application in a decent way.

Send Intent on Real Device

Postby heikki » Tue Mar 31, 2009 5:05 am

I would like to add the ability to send SMS and email from my application. I have found conflicting information on how to do this, and my tests on just the emulator haven't helped much.

I created a small sample application that has two buttons. One tries to launch a send activity using text/plain mime type, and the other message/rfc822 mime type. On the emulator with all the default software, all these do is pop up a dialog that says No application can perform this action. If I install K-9 and configure it, trying the text/plain button starts a new mail message in K-9.

Do either of the buttons let you choose an application to use for sending? If so, could you upload a screenshot?

Can you send SMS and email?

Your message should initialize with "My Subject Line" as the subject, and it should have two lines of content:

First line
Second line

Does it work like this for you? Both in SMS and email?

I have attached both the apk and source tarballs. If you notice any problems with the code, please let me know.
full sources
(5.7 KiB) Downloaded 265 times
(10.54 KiB) Downloaded 250 times
Posts: 8
Joined: Thu Feb 07, 2008 5:45 am


Postby stifry » Tue Mar 31, 2009 3:37 pm

It depends on the mime type. Send email (with an attachment) like this:

Code: Select all
String subject = "test subject";
            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/session.kmz"));

Send SMS like this:

Code: Select all
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "some text");
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm


Return to Promote your Android Application

Who is online

Users browsing this forum: No registered users and 4 guests