呼叫android系統自帶功能

2021-08-26 06:01:57 字數 4736 閱讀 5732

intent應該算是android中特有的東西。你可以在intent中指定程式要執行的動作(比如:view,edit,dial),以及程式執行到該動作時所需要的資料。都指定好後,只要呼叫startactivity(),android系統會自動尋找最符合你指定要求的應用程式,並執行該程式。

下面列出幾種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:******");

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

startactivity(it);

複製**

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

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

要使用這個必須在配置檔案中加入

複製**

傳送sms/mms

呼叫傳送簡訊的程式

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:0800000123");

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

it.putextra("sms_body", "the sms text");

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

複製**

傳送email

uri uri = uri.parse("mailto:***@abc.com");

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_send);

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

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

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

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

複製**

intent it = new intent(intent.action_view);

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

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

startactivity(it);

複製**

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

startactivity(it);

複製**

uninstall 程式

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

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

startactivity(it);

複製**

uninstall apk

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

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

複製**

install apk

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

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

複製**

play audio

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

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/eoe.***");

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

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

//搜尋應用

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

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

startactivity(it);

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

startactivity(it);

//page, and notice the id from the address bar

玩過android的都清楚, camera有倆種模式:照相模式和錄影模式。

啟動錄影模式:

intent i = new intent();

i.setaction(「android.media.action.video_camera「);

startactivity(i);

啟用照相模式:

intent i = new intent();

i.setaction(「android.media.action.still_image_camera「);

startactivity(i);

Android分享 呼叫系統自帶的分享功能

這裡就記錄下第一種辦法。intent textintent new intent intent.action send textintent.settype text plain textintent.putextra intent.extra text,這是一段分享的文字 startactivit...

Android系統自帶樣式

android theme android style theme.dialog activity顯示為對話方塊模式 android theme android style theme.notitlebar 不顯示應用程式標題欄 android theme android style theme.n...

Android呼叫系統簡訊功能傳送簡訊

android呼叫系統簡訊功能傳送簡訊有兩種方法,第一種,設定傳送的號碼,和內容,介面沒有聯絡人,群組組等按鈕,如下圖所示 如下 uri smstouri uri.parse smsto 114 聯絡人位址 intent mintent new intent android.content.inte...