通过彩信发送照片

时间:2012-07-23 21:04:29

标签: android sms mms

我正在尝试通过彩信发送照片,我正在使用以下已知代码段

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_TEXT, "This is an MMS message");
String sendfilepath = "file://" + sendfile.toString() + ".jpg";
i.putExtra(Intent.EXTRA_STREAM,Uri.parse(sendfilepath)) ;
i.setType("image/jpeg");

适用于我的Sony设备。弹出菜单显示消息传递应用程序以及其他应用程序。 但是使用HTC它不会显示消息应用程序。它显示了蓝牙,Facebook,邮件等。如何在“使用完整操作”列表中显示消息应用程序

1 个答案:

答案 0 :(得分:0)

您可以使用此技术检查HTC感应设备并做出适当反应以发送意图的正确“版本”。

Uri uri = Uri.fromFile(imgFile);
//HTC Sense intent
Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("image/"+type);
List<ResolveInfo> resolves = getPackageManager().queryIntentActivities(sendIntent,PackageManager.MATCH_DEFAULT_ONLY);
if (resolves.size() > 0) {
    // This branch is followed only for HTC 
    startActivity(sendIntent);
} else {
    // Else launch the non-HTC sense Intent
    sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    sendIntent.setType("image/"+type);
    startActivity(Intent.createChooser(sendIntent,"Send"));
}