本文整理汇总了Java中android.net.MailTo类的典型用法代码示例。如果您正苦于以下问题:Java MailTo类的具体用法?Java MailTo怎么用?Java MailTo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MailTo类属于android.net包,在下文中一共展示了MailTo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldOverrideUrlLoading
import android.net.MailTo; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("mailto:")) {
final Activity activity = mActivityRef.get();
if (activity != null) {
MailTo mt = MailTo.parse(url);
Intent i = newEmailIntent(activity, mt.getTo(), mt.getSubject(), mt.getBody(), mt.getCc());
activity.startActivity(i);
view.reload();
return true;
}
} else {
view.loadUrl(url);
}
return true;
}
示例2: extractAddress
import android.net.MailTo; //导入依赖的package包/类
private static Address extractAddress(String headerValue) {
if (headerValue == null || headerValue.isEmpty()) {
return null;
}
Matcher matcher = MAILTO_CONTAINER_PATTERN.matcher(headerValue);
if (!matcher.find()) {
return null;
}
String mailToUri = matcher.group(1);
String emailAddress = MailTo.parse(mailToUri).getTo();
return new Address(emailAddress);
}
示例3: shouldOverrideUrlLoading
import android.net.MailTo; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("file")) {
// Keep local assets in this WebView.
return false;
} else if (url.startsWith("mailto:")) {
try {
MailTo mt = MailTo.parse(url);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{mt.getTo()});
i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
context.startActivity(i);
view.reload();
}
catch (ActivityNotFoundException e) {
Log.w(TAG, "Problem with Intent.ACTION_SEND", e);
new AlertDialog.Builder(context)
.setTitle("Contact Info")
.setMessage( "Please send your feedback to: [email protected]" )
.setPositiveButton( "Done", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.d("AlertDialog", "Positive");
}
})
.show();
}
return true;
} else {
// Open external URLs in Browser.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
}
示例4: shouldOverrideUrlLoading
import android.net.MailTo; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("file")) {
// Keep local assets in this WebView.
return false;
} else if (url.startsWith("mailto:")) {
try {
MailTo mt = MailTo.parse(url);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{mt.getTo()});
i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
context.startActivity(i);
view.reload();
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Problem with Intent.ACTION_SEND", e);
new AlertDialog.Builder(context)
.setTitle("Contact Info")
.setMessage("Please send your feedback to: [email protected]")
.setPositiveButton("Done", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.d("AlertDialog", "Positive");
}
})
.show();
}
return true;
} else {
// Open external URLs in Browser.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
}
示例5: shouldOverrideUrlLoading
import android.net.MailTo; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// Check if configured proxy is available
if (mBrowserController.proxyIsNotReady()) {
// User has been notified
return true;
}
if (mIsIncognitoTab) {
return super.shouldOverrideUrlLoading(view, url);
}
if (url.startsWith("about:")) {
return super.shouldOverrideUrlLoading(view, url);
}
if (url.contains("mailto:")) {
MailTo mailTo = MailTo.parse(url);
Intent i = Utils.newEmailIntent(mailTo.getTo(), mailTo.getSubject(),
mailTo.getBody(), mailTo.getCc());
mActivity.startActivity(i);
view.reload();
return true;
} else if (url.startsWith("intent://")) {
Intent intent;
try {
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException ex) {
return false;
}
if (intent != null) {
try {
mActivity.startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.e(Constants.TAG, "ActivityNotFoundException");
}
return true;
}
}
return mIntentUtils.startActivityForUrl(mWebView, url);
}
示例6: onAddToContacts
import android.net.MailTo; //导入依赖的package包/类
@Override
public void onAddToContacts(String url) {
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
if (MailTo.isMailTo(url)) {
intent.putExtra(
ContactsContract.Intents.Insert.EMAIL, MailTo.parse(url).getTo().split(",")[0]);
} else if (UrlUtilities.isTelScheme(url)) {
intent.putExtra(ContactsContract.Intents.Insert.PHONE, UrlUtilities.getTelNumber(url));
}
IntentUtils.safeStartActivity(mTab.getActivity(), intent);
}
示例7: getEmailIntent
import android.net.MailTo; //导入依赖的package包/类
public static Intent getEmailIntent(MailTo mailTo) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { mailTo.getTo() });
intent.putExtra(Intent.EXTRA_TEXT, mailTo.getBody());
intent.putExtra(Intent.EXTRA_SUBJECT, mailTo.getSubject());
intent.putExtra(Intent.EXTRA_CC, mailTo.getCc());
intent.setType(INTENT_TYPE_MESSAGE_RFC822);
return intent;
}
示例8: showMailDialg
import android.net.MailTo; //导入依赖的package包/类
public static void showMailDialg(Context context, String url) {
MailTo mt = MailTo.parse(url);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL, new String[] { mt.getTo() });
i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
i.putExtra(Intent.EXTRA_CC, mt.getCc());
i.putExtra(Intent.EXTRA_TEXT, mt.getBody());
context.startActivity(i);
}
示例9: shouldOverrideUrlLoading
import android.net.MailTo; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("file")) {
if (url.contains("{html-lang}")) {
String page = url.substring(url.lastIndexOf('/') + 1);
view.loadUrl(BASE_HELP_URL + page);
return true;
}
return false;
} else if (url.startsWith("mailto:")) {
try {
MailTo mt = MailTo.parse(url);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{mt.getTo()});
i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
i.putExtra(Intent.EXTRA_TEXT, mt.getBody());
context.startActivity(i);
view.reload();
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Problem with Intent.ACTION_SEND", e);
new AlertDialog.Builder(context).setTitle("Contact Info")
.setMessage("Please send your feedback to: [email protected]")
.setPositiveButton("Done", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.d("AlertDialog", "Positive");
}
})
.show();
}
return true;
} else {
// Open external URLs in Browser.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
}
示例10: shouldOverrideUrlLoading
import android.net.MailTo; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
logger.d("webLoading:shouldOverrideUrlLoading");
// Check if configured proxy is available
// if (!mBrowserController.isProxyReady()) {
// // User has been notified
// return true;
// }
// if (mBrowserController.isIncognito()) {
// return super.shouldOverrideUrlLoading(view, url);
// }
if (url.startsWith("about:")) {
return super.shouldOverrideUrlLoading(view, url);
}
if (url.contains("mailto:")) {
MailTo mailTo = MailTo.parse(url);
Intent i = XmWebUtils.newEmailIntent(mailTo.getTo(), mailTo.getSubject(),
mailTo.getBody(), mailTo.getCc());
mContext.startActivity(i);
view.reload();
return true;
} else if (url.startsWith("intent://")) {
Intent intent;
try {
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException ex) {
return false;
}
if (intent != null) {
try {
mContext.startActivity(intent);
} catch (ActivityNotFoundException e) {
logger.e("ActivityNotFoundException");
}
return true;
}
}
return mIntentUtils.startActivityForUrl(XmWebView.this, url);
}