本文整理汇总了Java中org.andengine.util.mime.MIMEType类的典型用法代码示例。如果您正苦于以下问题:Java MIMEType类的具体用法?Java MIMEType怎么用?Java MIMEType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MIMEType类属于org.andengine.util.mime包,在下文中一共展示了MIMEType类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSendMailIntent
import org.andengine.util.mime.MIMEType; //导入依赖的package包/类
public static Intent getSendMailIntent(final Context pContext, final String [] pRecipients, final String pSubject, final String pBody) {
/* Attempt using ACTION_SENDTO: */
final Intent sendToIntent = new Intent(Intent.ACTION_SENDTO);
final StringBuilder sendToUriStringBuilder = new StringBuilder();
sendToUriStringBuilder.append("mailto:");
if (!org.andengine.util.TextUtils.isEmpty(pRecipients)) {
final String recipientsString = TextUtils.join(",", pRecipients);
sendToUriStringBuilder.append(Uri.encode(recipientsString));
}
if (!TextUtils.isEmpty(pSubject)) {
sendToUriStringBuilder.append("?subject=").append(Uri.encode(pSubject));
}
if (!TextUtils.isEmpty(pBody)) {
if (TextUtils.isEmpty(pSubject)) {
sendToUriStringBuilder.append("?body=");
} else {
sendToUriStringBuilder.append("&body=");
}
sendToUriStringBuilder.append(Uri.encode(pBody));
}
final String sendToUriString = sendToUriStringBuilder.toString();
final Uri sendToUri = Uri.parse(sendToUriString);
sendToIntent.setData(sendToUri);
if (IntentUtils.isIntentResolvable(pContext, sendToIntent)) {
return sendToIntent;
} else {
/* Fallback using ACTION_SEND: */
final Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType(MIMEType.TEXT.getTypeString());
if (!org.andengine.util.TextUtils.isEmpty(pRecipients)) {
sendIntent.putExtra(Intent.EXTRA_EMAIL, pRecipients);
}
if (!TextUtils.isEmpty(pSubject)) {
sendIntent.putExtra(Intent.EXTRA_SUBJECT, pSubject);
}
if (!TextUtils.isEmpty(pBody)) {
sendIntent.putExtra(Intent.EXTRA_TEXT, pBody);
}
return sendIntent;
}
}