简体   繁体   English

Android:有没有通用的方式在任何Android设备上发送彩信?

[英]Android: Is there a universal way to send the MMS on any android devices?

This code works on the plain google devices with native android system. 此代码适用于具有本机android系统的普通google设备。 But there is no MMS app in the list on htc sense devices and I don't know about Motorola Blur etc.: 但是在htc感应设备的列表中没有MMS应用程序,我不知道摩托罗拉模糊等:

    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: 这段代码适用于htc意义,但不适用于Chooser,我真正需要的是:

    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. 但我不知道如何将这些代码示例组合在一起,我不知道如何以编程方式确定Htc Sense ui。 Is it right way to support different type of devices? 是支持不同类型设备的正确方法吗?

Thank you for answers. 谢谢你的回答。

Sense, especially the older versions are a pain. 感觉,特别是旧版本是一种痛苦。 There webview control also has a bunch of problems. webview控件也有一堆问题。 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. 根据消息量的不同,您可以尝试使用像amazon的简单通知服务这样的Web服务来发送短信: http//aws.typepad.com/aws/2011/11/amazon-simple-notification-service-now-supports-sms .html它不是一个Android解决方案,但它可能会工作。

You could detect whether there's a responder for the HTC Intent, and then branch: 您可以检测是否有HTC Intent的响应者,然后分支:

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)));    
}

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM