啓動手機中存在的Activity時Intent傳入的數據小結
用 setType() 方法來指定intent附帶的數據類型。設置MIME
type 是爲了指定應該接受這個intent的activity。例如:
Intent intent=new Intent(Intent.ACTION_PICK)
intent.setType(Url url); 若在intent中沒有傳入Uri則setType(Uri uri)確定將啓動手機中哪個Activity,
uri-->content://com.example.app.provider/table1表示訪問的是com.example.app這個應用,table表示該應用的表
通配符表示方式:
content://com.example.app.provider/* 表示訪問該應用中任意表
content://com.example.app.provider/table/# 表示訪問該應用表table中任意一行
//對應啓動Activity有getStringExtra();根據傳過來的key判斷做什麼
//比如傳過來的是Intent.EXTRA_TEXT,則啓動email後所做的事就是將key所對應的values當作message text
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// The intent does not have a URI, so declare the "text/plain" MIME type
emailIntent.setType(HTTP.PLAIN_TEXT_TYPE);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"}); // recipients
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Email subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message text");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://path/to/email/attachment"));
intent.putExtra();