android developer tiny share-20160824
来源:互联网 发布:淘宝卖家怎么查看投诉 编辑:程序博客网 时间:2024/06/05 01:19
本节讲intent实现打车的功能,以及调用地图,以及播放媒体文件。
Local Actions
Call a carTo call a taxi, use the ACTION_RESERVE_TAXI_RESERVATION action.
Note: Apps must ask for confirmation from the user before completing the action.
Action
ACTION_RESERVE_TAXI_RESERVATION
Data URI
None
MIME Type
None
Extras
None
Example intent:
public void callCar() { Intent intent = new Intent(ReserveIntents.ACTION_RESERVE_TAXI_RESERVATION); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); }}
<activity ...> <intent-filter> <action android:name="com.google.android.gms.actions.RESERVE_TAXI_RESERVATION" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter></activity>
Maps
Show a location on a map
To open a map, use the ACTION_VIEW action and specify the location information in the intent data with one of the schemes defined below.
Action
ACTION_VIEW
Data URI Scheme
geo:latitude,longitude
Show the map at the given longitude and latitude.
Example: "geo:47.6,-122.3"
geo:latitude,longitude?z=zoom
Show the map at the given longitude and latitude at a certain zoom level. A zoom level of 1 shows the whole Earth, centered at the given lat,lng. The highest (closest) zoom level is 23.
Example: "geo:47.6,-122.3?z=11"
geo:0,0?q=lat,lng(label)
Show the map at the given longitude and latitude with a string label.
Example: "geo:0,0?q=34.99,-106.61(Treasure)"
geo:0,0?q=my+street+address
Show the location for "my street address" (may be a specific address or location query).
Example: "geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA"
Note: All strings passed in the geo URI must be encoded. For example, the string 1st & Pike, Seattle should become 1st%20%26%20Pike%2C%20Seattle. Spaces in the string can be encoded with %20 or replaced with the plus sign (+).
MIME Type
None
Example intent:
public void showMap(Uri geoLocation) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(geoLocation); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); }}
Example intent filter:
<activity ...> <intent-filter> <action android:name="android.intent.action.VIEW" /> <data android:scheme="geo" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter></activity>
Play a media file
To play a music file, use the ACTION_VIEW action and specify the URI location of the file in the intent data.
Action
ACTION_VIEW
Data URI Scheme
file:<URI>
content:<URI>
http:<URL>
MIME Type
"audio/*"
"application/ogg"
"application/x-ogg"
"application/itunes"
Or any other that your app may require.
Example intent:
public void playMedia(Uri file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(file); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); }}
Example intent filter:
<activity ...> <intent-filter> <action android:name="android.intent.action.VIEW" /> <data android:type="audio/*" /> <data android:type="application/ogg" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter></activity>
- android developer tiny share-20160824
- android developer tiny share-20160627
- android developer tiny share-20160628
- android developer tiny share-20160629
- android developer tiny share-20160630
- android developer tiny share-20160701
- android developer tiny share-20160704
- android developer tiny share-20160705
- android developer tiny share-20160706
- android developer tiny share-20160707
- android developer tiny share-20160708
- android developer tiny share-20160711
- android developer tiny share-20160712
- android developer tiny share-20160713
- android developer tiny share-20160714
- android developer tiny share-20160715
- android developer tiny share-20160718
- android developer tiny share-20160719
- Linux常用命令
- MAC中用到的终端命令大全更新
- 图片加载UIL的Disk缓存策略
- 顺序栈的基本操作
- handler——封装任务 Message
- android developer tiny share-20160824
- 学习hadoop需要具备基础知识
- 384.[LeetCode]First Unique Character in a String
- 如何在QT中实现C语言中调用C++的函数
- adfasdf
- 五十道编程小题目 --- 14 java
- B-tree/B+tree/B*tree
- Linux C 调用脚本
- 水题(Checkpoints,cf 709B)