您的位置:首页 > 大数据 > 人工智能

make phone call, browse web, send email

2012-04-10 18:24 260 查看
// make phone call

try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:1850363744"));
startActivity(callIntent);
} catch (ActivityNotFoundException e) {
Log.e("Dialing FAILED", "Call failed", e);
}

try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+448450730099"));
startActivity(callIntent);
} catch (ActivityNotFoundException e) {
Log.e("Dialing FAILED", "Call failed", e);
}
// browse web
try {
Intent webIntent = new Intent(Intent.ACTION_VIEW);
webIntent.setData(Uri.parse("http://www.energia.ie"));
startActivity(webIntent);
} catch (ActivityNotFoundException e) {
Log.e("Browsing FAILED", "Browser failed", e);
}

// send mail
try {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);

//Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Contact Energia - Smart App");
emailIntent.putExtra(Intent.EXTRA_TEXT, "");
emailIntent.setData(Uri.parse("mailto:customer.service@energia.ie")); // or just "mailto:" for blank
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this will make such that when user returns to your app, your app is displayed, instead of the email app.
startActivity(emailIntent);

} catch (ActivityNotFoundException e) {
Log.e("Dialing FAILED", "Call failed", e);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: