通过彩信发送照片

问题描述:

我试图通过发送彩信照片,我使用以下已知片断通过彩信发送照片

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

它与我的索尼设备。弹出菜单显示消息应用程序以及其他应用程序。 但与HTC它不显示消息应用程序。它显示了蓝牙,Facebook,邮件等。我如何让它显示在“完成操作使用”列表中的消息应用程序

您可以使用此技术来检查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")); 
} 
+0

它打开消息应用程序,但它不附加图像。你的意思是“+”是什么意思?我把(image/jpeg)错了吗? – yasserbn 2012-07-23 22:01:08

+0

它将是你的图像的任何类型的文件,在我的应用程序中,我有一些不同类型的图像(PNG,JPEG等),所以我不得不做出动态。如果你只有jpegs,那么你应该可以使用''image/jpeg''' – FoamyGuy 2012-07-24 00:37:42