Intent 呼叫事例

2021-06-18 23:39:57 字數 4641 閱讀 2810

//聯絡人呼叫

插入聯絡人介面 (for api<4)

intent intent=new intent();

intent.setaction(intent.action_insert);

intent.setdata(contacts.people.content_uri);

startactivity(intent);

插入聯絡人介面 (for api>4)

intent.setaction(intent.action_insert);

intent.settype("vnd.android.cursor.dir/person");

intent.settype("vnd.android.cursor.dir/contact");

intent.settype("vnd.android.cursor.dir/raw_contact");

//呼叫瀏覽工具

intent intent = new intent();

intent.setaction(android.content.intent.action_view);

intent.setdataandtype(uri.fromfile(file), "image/*");

startactivity(intent);

//呼叫瀏覽器

uri uri = uri.parse("");

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("");

intent it = new intent(intent.action_view,uri);

startactivity(it);

//撥打**

uri uri = uri.parse("tel:10086");

intent it = new intent(intent.action_dial, uri); 

startactivity(it); 

uri uri = uri.parse("tel.10086");

intent it =new intent(intent.action_call,uri);

需要新增 這個許可權到androidmanifest.xml

//傳送簡訊或彩信

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("smsto:10086");  

intent it = new intent(intent.action_sendto, uri);  

it.putextra("sms_body", "cwj");  

startactivity(it); 

//傳送彩信

uri uri = uri.parse("content://media/external/images/media/23");  

intent it = new intent(intent.action_send);  

it.putextra("sms_body", "some text");  

it.putextra(intent.extra_stream, uri);  

it.settype("image/png");  

startactivity(it);

//傳送郵件

uri uri = uri.parse("mailto:[email protected]");

intent it = new intent(intent.action_sendto, uri);

startactivity(it);

intent it = new intent(intent.action_send);  

it.putextra(intent.extra_email, [email protected]);  

it.putextra(intent.extra_text, "the email body text");  

it.settype("text/plain");  

startactivity(intent.createchooser(it, "choose email client")); 

intent it=new intent(intent.action_send);    

string tos=;    

string ccs=;    

it.putextra(intent.extra_email, tos);    

it.putextra(intent.extra_cc, ccs);    

it.putextra(intent.extra_text, "the email body text");    

it.putextra(intent.extra_subject, "the email subject text");    

it.settype("message/rfc822");    

startactivity(intent.createchooser(it, "choose email client"));  

intent it = new intent(intent.action_view);

uri uri = uri.parse("file:///sdcard/cwj.***");

it.setdataandtype(uri, "audio/***");

startactivity(it);

//呼叫照相機

intent it=new intent(mediastore.action_image_capture);

intent.putextra(mediastore.extra_output, uri.fromfile("***"));//儲存**到指定的路徑,不過某些相機不會按照指定目錄儲存的。

startactivityforresult(intent, "***");

//解除安裝apk

uri uri = uri.fromparts("package", strpackagename, null);  

intent it = new intent(intent.action_delete, uri);  

startactivity(it);

//解除安裝apk 2

uri uninstalluri = uri.fromparts("package", "***", null);

returnit = new intent(intent.action_delete, uninstalluri);

//安裝apk

uri installuri = uri.fromparts("package", "***", null);

returnit = new intent(intent.action_package_added, installuri);

uri playuri = uri.parse("file:///sdcard/download/sth.***");

returnit = new intent(intent.action_view, playuri);

//傳送附近

intent it = new intent(intent.action_send); 

it.putextra(intent.extra_subject, "the email subject text"); 

it.putextra(intent.extra_stream, "file:///sdcard/cwj.***"); 

sendintent.settype("audio/***"); 

startactivity(intent.createchooser(it, "choose email client"));

//market上某個應用信,pkg_name就是應用的packagename

uri uri = uri.parse("market://search?q=pname:pkg_name"); 

intent it = new intent(intent.action_view, uri); 

startactivity(it); 

//呼叫搜尋

intent intent = new intent();

intent.setaction(intent.action_web_search);

intent.putextra(searchmanager.query,"android123")

startactivity(intent);

ack 安裝和使用事例

安裝 curl bin ack chmod 0755 3 事例 0 在the dir目錄中ack預設的所有檔案型別中查詢並輸出匹配結果 ack akara 1 在the dir目錄中的所有檔案 包括二進位制的 查詢並輸出匹配結果 ack u akara 2 列印出the dir中 包含子目錄 所有的...

js的建構函式共用事例

在使用建構函式去實現一種功能時,我們有時候往往需要實現這個功能,會因此產生多個堆內物件。這樣就會造成堆記憶體濫用。占用不該占用的空間。為此我們可以利用函式把共用的內容封裝起來。放便我們的使用。很多東西其實都是基於堆與棧的,深入理解一下更有利於學習計算機。不算字這個限制什麼時候可以消除呢。來自版主的吐...

Intent呼叫大全

呼叫瀏覽器 uri uri uri.parse intent it new intent intent.action view,uri startactivity it 顯示某個座標在地圖上 uri uri uri.parse geo 38.899533,77.036476 intent it ne...