ID | 功能 | code |
1 | 開啟網頁, 需要網址 | Uri uri= Uri.parse("http://google.com.tw"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); |
2 | 開啟地圖, 需要經緯度座標 | Uri mapUri = Uri.parse("geo:25.183505,121.528873"); Intent intent = new Intent(Intent.ACTION_VIEW, mapUri); startActivity(intent); |
3 | 開啟電話AP, 並填入電話號碼 | Uri telUri = Uri.parse("tel:0228825252"); Intent intent = new Intent(Intent.ACTION_DIAL, telUri); startActivity(intent); |
4 | 播打電話, 需要電話號碼 | //得先在 AndroidManifest.xml 中加上<uses-permission id="android.permission.CALL_PHONE" /> Uri callUri = Uri.parse("tel:0228825252"); Intent intent = new Intent(Intent.ACTION_CALL, callUri); startActivity(intent); |
5 | uninstall AP, 需要package名稱 | Uri uninstallUri = Uri.fromParts("package", "com.tsots.contacts", null); Intent intent = new Intent(Intent.ACTION_DELETE, uninstallUri); startActivity(intent); |
6 | install AP, 需要package名稱 | Uri installUri = Uri.fromParts("package", "com.tsots.contacts", null); Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); startActivity(intent); |
7 | 播放多媒體, 需要檔案絕對路徑 | Uri uri = Uri.parse("file:///sdcard/media/music.mp3"); Intent intent = new Intent(Intent.ACTION_VIEW, playUri); intent.setDataAndType(uri, "audio/mp3"); startActivity(intent); |
8 | 發郵件, 需要mail address | //Uri emailUri = Uri.parse("mailto:beddingfair@gmail.com"); //Intent intent = new Intent(Intent.ACTION_SENDTO, emailUri); Intent intent = new Intent(Intent.ACTION_SEND); String[] tos = { "beddingfair@gmail.com" }; String[] ccs = { "other@gmail.com" }; intent.putExtra(Intent.EXTRA_EMAIL, tos); intent.putExtra(Intent.EXTRA_CC, ccs); intent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); intent.putExtra(Intent.EXTRA_TEXT, "Content"); intent.setType("message/rfc882"); startActivity(Intent.createChooser(it, "Choose Email Client")); |
9 | 開啟簡訊AP, 並填入電話號碼&內文 | Uri smsUri = Uri.parse("tel:0988123456"); Intent intent = new Intent(Intent.ACTION_VIEW, smsUri); intent.putExtra("sms_body", "HelloDear"); intent.setType("vnd.android-dir/mms-sms"); startActivity(intent); |
10 | 傳送簡訊, 需要電話號碼&內文 | Uri uri = Uri.parse("mmsto:<number>"); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("address", "0988123456"); intent.putExtra("subject", "HelloDear"); startActivity(intent); |
11 | 傳送影音附件檔, 需要檔案位置&內文 | Uri uri = Uri.parse("file:///sdcard/media/music.mp3"); Intent it = new Intent(Intent.ACTION_SEND); it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text"); it.putExtra(Intent.EXTRA_STREAM, uri); it.setType("audio/mp3"); startActivity(Intent.createChooser(it, "Choose Email Client")); |
12 | 傳送圖片附件檔, 需要檔案位置&內文 | Uri uri = Uri.parse("file:///sdcard/dcim/pic.jpg"); Intent it = new Intent(Intent.ACTION_SEND); it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text"); it.putExtra(Intent.EXTRA_STREAM, uri); it.setType("image/jpeg"); startActivity(Intent.createChooser(it, "Choose Email Client")); |
13 | 啟動照相機,拍照後將相片存在指定檔案 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //將相片存在 /sdcard/dcim/pic.jpg 中 File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/dcim/pic.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); startActivity(intent, 0); |
14 | 尋找Market上某AP, 需要package名稱 | Uri uri = Uri.parse("market://search?q=pname:com.tsots.contacts"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); |
總網頁瀏覽量
基礎Note
☪About Me
(1)
免費軟體
(2)
教學
(4)
教學文件
(42)
會計軟體
(1)
電腦系統
(1)
Adapter
(8)
Adobe Premiere
(1)
AlertDialog
(7)
Android App 介紹
(1)
Animation
(1)
API
(2)
APP範例
(1)
Array
(1)
AsyncTask
(1)
Auto Test Case
(32)
AutoCompleteTextView
(1)
Bitmap Drawable
(3)
BroadcastReceiver
(4)
Button
(1)
Codility
(2)
Contact
(4)
DB
(1)
Dialog
(2)
Documents
(1)
Eclipse
(3)
Ellipsize
(1)
File
(4)
Focus
(2)
Fragment
(4)
Gallery
(2)
GIT
(4)
GitHub
(1)
GridView
(8)
HashMap
(1)
HorizontalScrollView
(6)
IIS
(1)
Intent
(3)
IntentService
(1)
Internet
(2)
KeyEvent
(1)
Layout
(1)
ListView
(11)
Log
(1)
Mac / iOS
(11)
Manifest
(1)
Marquee
(2)
Math
(1)
MediaPlayer
(5)
MediaRecorder
(5)
MSMQ
(1)
onClick
(1)
PackageManager
(6)
PHP
(1)
PIS
(3)
PowerManager
(1)
Progress
(2)
SCREEN
(1)
Search
(6)
Service
(1)
SharedPreferences
(3)
SimpleDateFormat
(1)
SonarQube
(1)
Sound Recorder
(1)
Spinner
(2)
SQL server Management
(16)
SQLite
(13)
String
(1)
STS
(5)
SVN
(1)
Thread
(1)
Toast
(3)
Typeface
(1)
Uri
(2)
VB.NET
(17)
VMware
(1)
關於我自己
2012年3月6日 星期二
以Uri為主的應用
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言