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.
Attachments
SendIntent.tar.gz
full sources
(5.7 KiB) Downloaded 116 times
SendIntent.apk
package
(10.54 KiB) Downloaded 122 times
heikki
Freshman
Freshman
 
Posts: 8
Joined: Thu Feb 07, 2008 5:45 am

Top

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"));
            sendIntent.setType("application/vnd.google-earth.kmz");


Send SMS like this:

Code: Select all
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "some text");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Top

Return to Promote your Android Application

Who is online

Users browsing this forum: No registered users and 3 guests