android Intent 多种用法全面介绍
2010-06-04 14:20:00 来源:WEB开发网4.
5. < application android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar" >
6. < activity android:name=".FormStuff" android:label="@string/app_name" >
7. < intent-filter >
8. < action android:name="android.intent.action.MAIN" / >
9. < category android:name="android.intent.category.LAUNCHER" / >
10. < /intent-filter >
11. < /activity >
12. < !-- 申明activity-- >
13. < activity android:name="HelloTabWidget" >< /activity >
14. < /application >
15. < uses-sdk android:minSdkVersion="4" / >
16. < /manifest >
下面列出几种Intent的用法
显示网页:
1. Uri uri = Uri.parse("http://www.google.com");
2. Intent it = new Intent(Intent.ACTION_VIEW,uri);
3. startActivity(it);
显示地图:
1. Uri uri = Uri.parse("geo:38.899533,-77.036476");
2. Intent it = new Intent(Intent.Action_VIEW,uri);
3. startActivity(it);
路径规划:
1. Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
2. Intent it = new Intent(Intent.ACTION_VIEW,URI);
3. startActivity(it);
拨打电话:
调用拨号程序
1. Uri uri = Uri.parse("tel:xxxxxx");
2. Intent it = new Intent(Intent.ACTION_DIAL, uri);
3. startActivity(it);
1. Uri uri = Uri.parse("tel.xxxxxx");
2. Intent it =new Intent(Intent.ACTION_CALL,uri);
3. 要使用这个必须在配置文件中加入< uses-permission id="android.permission.CALL_PHONE" / >
发送SMS/MMS
调用发送短信的程序
1. Intent it = new Intent(Intent.ACTION_VIEW);
2. it.putExtra("sms_body", "The SMS text");
更多精彩
赞助商链接