2010-06-02 75 views
24

此代码适用于原生Android系统的纯谷歌设备。但在HTC Sense的设备列表中没有MMS应用程序,我不知道摩托罗拉模糊等:Android:在任何Android设备上是否有通用的方式发送彩信?

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。支持不同类型的设备是否正确?

谢谢你的回答。

+3

你见过[这个问题] [1] ?它有一些示例代码。 [1]:http://stackoverflow.com/questions/2972845/i-want-send-image-through-using-mms-in-android/2973016#2973016 – EboMike 2011-09-22 21:45:42

+0

@EboMike我看你是创造EboBirthday的家伙谢谢!这是一个非常棒的程序,自它首次发布以来一直在使用它。 – JPM 2011-11-01 23:33:09

+0

@JPM我是,谢谢JPM :) – EboMike 2011-11-01 23:52:21

回答

1

你可以检测是否有针对HTC意图响应,然后分支:

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

我在做类似的事情! http://stackoverflow.com/questions/14452808/sending-and-receiving-mms-in-android – toobsco42 2013-01-22 06:34:45

1

你可以使用这样的:

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