Android:是否有在任何 Android 设备上发送彩信的通用方法?

发布于 2024-09-03 11:39:44 字数 750 浏览 9 评论 0原文

此代码适用于具有本机 Android 系统的普通 Google 设备。但是 htc sense 设备上的列表中没有 MMS 应用程序,我不知道 Motorola Blur 等:

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

此代码适用于 htc sense,但不适用于选择器,我真正需要的是:

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

但我不知道如何将此代码示例组合在一起,我不知道如何以编程方式确定 Htc Sense ui。支持不同类型设备的正确方法吗?

谢谢您的解答。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

懒猫 2024-09-10 11:39:44

感觉,尤其是旧版本是一种痛苦。还有webview控件也有一堆问题。根据消息量,您可以尝试使用诸如亚马逊简单通知服务之类的网络服务来发送短信:http://aws.typepad.com/aws/2011/11/amazon-simple-notification-service-now-supports-sms.html
它不是 Android 解决方案,但它可能有效。

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.

多彩岁月 2024-09-10 11:39:44

您可以检测 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 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)));    
}
烟花肆意 2024-09-10 11:39:44

你可以这样使用它:

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文