24

This code works on the plain google devices with native android system. But there is no MMS app in the list on htc sense devices and I don't know about Motorola Blur etc.:

    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("image/png");
    emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
    context.startActivity(Intent.createChooser(emailIntent, context.getString(R.string.send_intent_name)));

This code works on the htc sense but not from the Chooser, what I really need:

    Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    sendIntent.setType("image/png");
    context.startActivity(sendIntent);

But I don't know how to combine this code samples together and I don't know how to determine Htc Sense ui programmatically. Is it right way to support different type of devices?

Thank you for answers.

shinydev
  • 759
  • 2
  • 7
  • 20
  • 3
    Have you seen [this question][1]? It has some sample code. [1]: http://stackoverflow.com/questions/2972845/i-want-send-image-through-using-mms-in-android/2973016#2973016 – EboMike Sep 22 '11 at 21:45

3 Answers3

1

Sense, especially the older versions are a pain. There webview control also has a bunch of problems. Depending on volume of messages you might try using a webservice like amazon's simple notification service to send sms messages: http://aws.typepad.com/aws/2011/11/amazon-simple-notification-service-now-supports-sms.html Its not an android solution, but it might work.

James Becwar
  • 1,176
  • 2
  • 11
  • 20
1

You could detect whether there's a responder for the HTC Intent, and then branch:

intent = new Intent("android.intent.action.SEND_MSG");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");

resolves = getActivity().getPackageManager().queryIntentActivities(intent,
        PackageManager.MATCH_DEFAULT_ONLY);

if (resolves.size() > 0) {
    // This branch is followed only for HTC 
    context.startActivity(intent);
} else {
    // Else launch the non-HTC sense Intent
    intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("image/png");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    context.startActivity(Intent.createChooser(intent,
            context.getString(R.string.send_intent_name)));    
}
nmr
  • 16,625
  • 10
  • 53
  • 67
1

You may use it like this:

Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
i.setType("video/3gp");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + attachmentFilePath));
startActivity(i);
Alexander
  • 23,432
  • 11
  • 63
  • 73
Anup Rojekar
  • 1,093
  • 9
  • 29