美文网首页
Intent调用常见系统组件

Intent调用常见系统组件

作者: 带带我 | 来源:发表于2021-02-26 15:54 被阅读0次
    // 调用浏览器
    
    Uri webViewUri = Uri.parse(``"[http://blog.csdn.net/zuolongsnail](http://blog.csdn.net/zuolongsnail)"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_VIEW, webViewUri);
    
    // 调用地图
    
    Uri mapUri = Uri.parse(``"geo:100,100"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_VIEW, mapUri);
    
    // 播放mp3
    
    Uri playUri = Uri.parse(``"file:///sdcard/test.mp3"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_VIEW, playUri);
    
    intent.setDataAndType(playUri,` `"audio/mp3"``);
    
    // 调用拨打电话
    
    Uri dialUri = Uri.parse(``"tel:10086"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_DIAL, dialUri);
    
    // 直接拨打电话,需要加上权限<uses-permission id="android.permission.CALL_PHONE" />
    
    Uri callUri = Uri.parse(``"tel:10086"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_CALL, callUri);
    
    // 调用发邮件(这里要事先配置好的系统Email,否则是调不出发邮件界面的)
    
    Uri emailUri = Uri.parse(``"mailto:zuolongsnail@163.com"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_SENDTO, emailUri);
    
    // 直接发邮件
    
    Intent intent =` `new` `Intent(Intent.ACTION_SEND);
    
    String[] tos = {` `"zuolongsnail@gmail.com"` `};
    
    String[] ccs = {` `"zuolongsnail@163.com"` `};
    
    intent.putExtra(Intent.EXTRA_EMAIL, tos);
    
    intent.putExtra(Intent.EXTRA_CC, ccs);
    
    intent.putExtra(Intent.EXTRA_TEXT,` `"the email text"``);
    
    intent.putExtra(Intent.EXTRA_SUBJECT,` `"subject"``);
    
    intent.setType(``"text/plain"``);
    
    Intent.createChooser(intent,` `"Choose Email Client"``);
    
    // 发短信
    
    Intent intent =` `new` `Intent(Intent.ACTION_VIEW);
    
    intent.putExtra(``"sms_body"``,` `"the sms text"``);
    
    intent.setType(``"vnd.android-dir/mms-sms"``);
    
    // 直接发短信
    
    Uri smsToUri = Uri.parse(``"smsto:10086"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_SENDTO, smsToUri);
    
    intent.putExtra(``"sms_body"``,` `"the sms text"``);
    
    // 发彩信
    
    Uri mmsUri = Uri.parse(``"content://media/external/images/media/23"``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_SEND);
    
    intent.putExtra(``"sms_body"``,` `"the sms text"``);
    
    intent.putExtra(Intent.EXTRA_STREAM, mmsUri);
    
    intent.setType(``"image/png"``);
    
    // 卸载应用
    
    Uri uninstallUri = Uri.fromParts(``"package"``,` `"com.app.test"``,` `null``);
    
    Intent intent =` `new` `Intent(Intent.ACTION_DELETE, uninstallUri);
    
    // 安装应用
    
    Intent intent =` `new` `Intent(Intent.ACTION_VIEW);
    
    intent.setDataAndType(Uri.fromFile(``new` `File(``"/sdcard/test.apk"``),` `"application/vnd.android.package-archive"``);
    
    // 在Android Market中查找应用
    
    Uri uri = Uri.parse(``"market://search?q=愤怒的小鸟"``);  
    
    Intent intent =` `new` `Intent(Intent.ACTION_VIEW, uri);
    

    相关文章

      网友评论

          本文标题:Intent调用常见系统组件

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