本文整理汇总了Java中android.net.MailTo.parse方法的典型用法代码示例。如果您正苦于以下问题:Java MailTo.parse方法的具体用法?Java MailTo.parse怎么用?Java MailTo.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.MailTo
的用法示例。
在下文中一共展示了MailTo.parse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}
示例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) {
// 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);
}
示例5: 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);
}
示例6: 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;
}
}
示例7: 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);
}