android调用系统功能,电话,分享,网页


//拨打电话,分享,打开网页

// 实例化一个意图(动作),用来拨打电话
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:10086");
startActivity(intent); // 封装一个意图

// 打开电子市场,网页
Uri uri = Uri.parse("market://details?id=com.jjmmbb.jxSudoku");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);


//分享
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain"); // 纯文本
/*图片分享
it.setType("image/png");
//添加图片
File f = new File(Environment.getExternalStorageDirectory() +"/Pictures/2.png");
Uri u = Uri.fromFile(f);
it.putExtra(Intent.EXTRA_STREAM, u);
*/
String sb="分享文本";
intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_TEXT, sb);
startActivity(Intent.createChooser(intent, getTitle()));


猜你喜欢

转载自zheyiw.iteye.com/blog/1782657
今日推荐