美文网首页
Intent 隐式跳转 调用系统应用

Intent 隐式跳转 调用系统应用

作者: 简爱_2 | 来源:发表于2018-03-31 01:37 被阅读0次

    1 使用浏览器浏览网页

    //web浏览器 

    Uri uri= Uri.parse("http://www.baidu.com"); 

    Intent intent =new Intent(Intent.ACTION_VIEW, uri); 

    startActivity(intent); 

    2 调用地图

    //打开地图查看经纬度 

    Uri uri = Uri.parse("geo:38.899533,-77.036476"); 

    Intent intent =new Intent(Intent.ACTION_VIEW, uri); 

    startActivity(intent); 

    3 调用电话拨号(不需要拨号权限)

    Uri uri = Uri.parse("tel:10086"); 

    Intent intent =new Intent(Intent.ACTION_DIAL, uri);//注意区别于下面4.4的action 

    startActivity(intent); 

    4 调用电话直接拨号(需要拨号权限)

    Uri uri = Uri.parse("tel:15980665805"); 

    Intent intent =new Intent(Intent.ACTION_CALL, uri);

    5 调用短信程序(无需发送短信权限,接收者自填)

    Intent intent = new Intent(Intent.ACTION_VIEW);     

    intent.putExtra("sms_body", "这里写短信内容");     

    intent.setType("vnd.android-dir/mms-sms");     

    startActivity(intent); 

    6 调用短信程序(无需发送短信权限)

    Uri uri = Uri.parse("smsto:10086");//指定接收者 

    Intent intent =new Intent(Intent.ACTION_SENDTO, uri); 

    intent.putExtra("sms_body", "你这个黑心运营商"); 

    startActivity(intent); 

    7 调用邮件程序

    Intent intent = new Intent(Intent.ACTION_SENDTO); 

    intent.setData(Uri.parse("mailto:xxx@gmail.com")); 

    intent.putExtra(Intent.EXTRA_SUBJECT,"这是标题"); 

    intent.putExtra(Intent.EXTRA_TEXT,"这是内容"); 

    startActivity(intent); 

    8 调用音乐播放器

    Intent intent = new Intent(Intent.ACTION_VIEW); 

    Uri uri = Uri.parse("file:///sdcard/xiong_it.mp3"); 

    intent.setDataAndType(uri,"audio/mp3"); 

    startActivity(intent); 

    9 调用视频播放器

    Intent intent = new Intent(Intent.ACTION_VIEW); 

    Uri uri = Uri.parse("file:///sdcard/xiong_it.mp4"); 

    intent.setDataAndType(uri,"video/mp4"); 

    startActivity(intent); 

    调用视频播放器和音乐播放器的区别在setDataAndType()时一个是audio类型,一个是video类型,很容易记住,不允许使用其他意思相近的单词代替,代替无效。

    10 调用搜索

    Intent intent = new Intent(); 

    intent.setAction(Intent.ACTION_WEB_SEARCH); 

    intent.putExtra(SearchManager.QUERY,"android"); 

    startActivity(intent); 

    相关文章

      网友评论

          本文标题:Intent 隐式跳转 调用系统应用

          本文链接:https://www.haomeiwen.com/subject/zxobcftx.html