AndroidIntent的几种用法全面总结.doc
上传者:小健
2022-06-02 09:22:51上传
DOC文件
85 KB
Android Intent的几种用法全面总结
Intent,用法
Intent应该算是Android中特有的东西。你可以在Intent中指定程序要执行的 动作(比如:view, edit, dial),以及程序执行到该动作时所需要的资料。都指 定好后,只要调用startActivity (), Android系统会自动寻找最符合你指定要 求的应用程序,并执行该程序。
下面列出几种Intent的用法
显木网页:
Uri uri = Uri. parse (/zhttp://www. google. comzz);
Intent it = new Intent(Intent. ACTION_VIEW, uri);
startActivity(it);
复制代码
显示地图:
Uri uri = Uri. parse ("geo: 38. 899533,—77. 036476〃);
Intent it = new Intent(Intent. Action_VIEW, uri);
startActivity(it);
复制代码
路径规划:
Uri uri =
Uri. parse (/zhttp://maps. google. com/maps?f=d&saddr=startLat%20sta rtLng&daddr=endLat%20endLng&hl=enzz);
Intent it = new Intent(Intent. ACTI0N_VIEW, URI);
startActivity(it);
复制代码
拨打电话:
调用拨号程序
Uri uri = Uri, parse(〃tel:xxxxxx〃);
Intent it 二 new Intent (Intent. ACTI0N_DIAL, uri);
startActivity(it);
复制代码
Uri uri = Uri. parse (/ztel. xxxxxx/z);
Intent it =new Intent (Intent. ACTI0N_CALL, uri);
要使用这个必须在配置文件中加入<uses-permission
id=〃android, permission. CALL_PHONE〃 />
复制代码
发送 SMS/MMS
调用发送短信的程序
Intent it 二 new Intent (Intent. ACTION VIEW);
it・putExtra(〃sms_body〃, 〃The SMS text〃);
it.setType (〃vnd・ android-dir/mms-sms^);
startActivity(it);
复制代码
发送短信
Uri uri 二 Uri. parse (zzsmsto:0800000123zz);
Intent it 二 new Intent(Intent. ACTION_SENDTO, uri);
it・putExtra(〃sms_body〃, 〃The SMS text〃);
startActivity(it);
复制代码
发送彩信
Uri uri 二
Uri. parse ("content://media/external/ima
Intent,用法
Intent应该算是Android中特有的东西。你可以在Intent中指定程序要执行的 动作(比如:view, edit, dial),以及程序执行到该动作时所需要的资料。都指 定好后,只要调用startActivity (), Android系统会自动寻找最符合你指定要 求的应用程序,并执行该程序。
下面列出几种Intent的用法
显木网页:
Uri uri = Uri. parse (/zhttp://www. google. comzz);
Intent it = new Intent(Intent. ACTION_VIEW, uri);
startActivity(it);
复制代码
显示地图:
Uri uri = Uri. parse ("geo: 38. 899533,—77. 036476〃);
Intent it = new Intent(Intent. Action_VIEW, uri);
startActivity(it);
复制代码
路径规划:
Uri uri =
Uri. parse (/zhttp://maps. google. com/maps?f=d&saddr=startLat%20sta rtLng&daddr=endLat%20endLng&hl=enzz);
Intent it = new Intent(Intent. ACTI0N_VIEW, URI);
startActivity(it);
复制代码
拨打电话:
调用拨号程序
Uri uri = Uri, parse(〃tel:xxxxxx〃);
Intent it 二 new Intent (Intent. ACTI0N_DIAL, uri);
startActivity(it);
复制代码
Uri uri = Uri. parse (/ztel. xxxxxx/z);
Intent it =new Intent (Intent. ACTI0N_CALL, uri);
要使用这个必须在配置文件中加入<uses-permission
id=〃android, permission. CALL_PHONE〃 />
复制代码
发送 SMS/MMS
调用发送短信的程序
Intent it 二 new Intent (Intent. ACTION VIEW);
it・putExtra(〃sms_body〃, 〃The SMS text〃);
it.setType (〃vnd・ android-dir/mms-sms^);
startActivity(it);
复制代码
发送短信
Uri uri 二 Uri. parse (zzsmsto:0800000123zz);
Intent it 二 new Intent(Intent. ACTION_SENDTO, uri);
it・putExtra(〃sms_body〃, 〃The SMS text〃);
startActivity(it);
复制代码
发送彩信
Uri uri 二
Uri. parse ("content://media/external/ima
AndroidIntent的几种用法全面总结