• Intent调用常见系统组件


     1 // 调用浏览器  
     2 Uri webViewUri = Uri.parse("http://blog.csdn.net/zuolongsnail");  
     3 Intent intent = new Intent(Intent.ACTION_VIEW, webViewUri);  
     4   
     5 // 调用地图  
     6 Uri mapUri = Uri.parse("geo:100,100");  
     7 Intent intent = new Intent(Intent.ACTION_VIEW, mapUri);  
     8   
     9 // 播放mp3  
    10 Uri playUri = Uri.parse("file:///sdcard/test.mp3");  
    11 Intent intent = new Intent(Intent.ACTION_VIEW, playUri);  
    12 intent.setDataAndType(playUri, "audio/mp3");  
    13   
    14 // 调用拨打电话  
    15 Uri dialUri = Uri.parse("tel:10086");  
    16 Intent intent = new Intent(Intent.ACTION_DIAL, dialUri);  
    17 // 直接拨打电话,需要加上权限<uses-permission id="android.permission.CALL_PHONE" />  
    18 Uri callUri = Uri.parse("tel:10086");  
    19 Intent intent = new Intent(Intent.ACTION_CALL, callUri);  
    20   
    21 // 调用发邮件(这里要事先配置好的系统Email,否则是调不出发邮件界面的)  
    22 Uri emailUri = Uri.parse("mailto:zuolongsnail@163.com");  
    23 Intent intent = new Intent(Intent.ACTION_SENDTO, emailUri);  
    24 // 直接发邮件  
    25 Intent intent = new Intent(Intent.ACTION_SEND);  
    26 String[] tos = { "zuolongsnail@gmail.com" };  
    27 String[] ccs = { "zuolongsnail@163.com" };  
    28 intent.putExtra(Intent.EXTRA_EMAIL, tos);  
    29 intent.putExtra(Intent.EXTRA_CC, ccs);  
    30 intent.putExtra(Intent.EXTRA_TEXT, "the email text");  
    31 intent.putExtra(Intent.EXTRA_SUBJECT, "subject");  
    32 intent.setType("text/plain");  
    33 Intent.createChooser(intent, "Choose Email Client");  
    34   
    35 // 发短信  
    36 Intent intent = new Intent(Intent.ACTION_VIEW);  
    37 intent.putExtra("sms_body", "the sms text");  
    38 intent.setType("vnd.android-dir/mms-sms");  
    39 // 直接发短信  
    40 Uri smsToUri = Uri.parse("smsto:10086");  
    41 Intent intent = new Intent(Intent.ACTION_SENDTO, smsToUri);  
    42 intent.putExtra("sms_body", "the sms text");  
    43 // 发彩信  
    44 Uri mmsUri = Uri.parse("content://media/external/images/media/23");  
    45 Intent intent = new Intent(Intent.ACTION_SEND);  
    46 intent.putExtra("sms_body", "the sms text");  
    47 intent.putExtra(Intent.EXTRA_STREAM, mmsUri);  
    48 intent.setType("image/png");  
    49   
    50 // 卸载应用  
    51 Uri uninstallUri = Uri.fromParts("package", "com.app.test", null);  
    52 Intent intent = new Intent(Intent.ACTION_DELETE, uninstallUri);  
    53 // 安装应用  
    54 Intent intent = new Intent(Intent.ACTION_VIEW);  
    55 intent.setDataAndType(Uri.fromFile(new File("/sdcard/test.apk"), "application/vnd.android.package-archive");  
    56   
    57 // 在Android Market中查找应用  
    58 Uri uri = Uri.parse("market://search?q=愤怒的小鸟");           
    59 Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
  • 相关阅读:
    复杂对象类型的WebService高级部分
    linux 免输入密码脚本
    查看端口是否被占用
    shell将脚本输出结果记录到日志文件
    多线程注意点
    apache Tomcat配置SSL(https)步骤
    常用的web安全处理
    SQL 中的 UNION 和UNION ALL 的区别
    数据库和数据仓库区别
    Oracle数据库创建表是有两个约束带有默认索引
  • 原文地址:https://www.cnblogs.com/blog4wei/p/9667557.html
Copyright © 2020-2023  润新知