Intent的幾種用法

2021-05-24 13:25:37 字數 3515 閱讀 4559

顯示網頁

顯示地圖

1. uri uri = uri.parse("geo:38.899533,-77.036476");   

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

3. startactivity(it);    

4. //

其他geo uri 

範例5. //geo:latitude,longitude   

6. //geo:latitude,longitude?z=zoom   

7. //geo:0,0?q=my+street+address   

8. //geo:0,0?q=business+near+city   

9. //google.streetview:cbll=lat,lng&cbp=1,yaw,,pitch,zoom&mz=mapzoom  

路徑規劃

打**1. //

叫出撥號程式

2. uri uri = uri.parse("tel:0800000123");   

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

4. startactivity(it);   

1. //

直接打**出去

2. uri uri = uri.parse("tel:0800000123");   

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

4. startactivity(it);   

5. //

用這個,要在

androidmanifest.xml 

中,加上

6. //

傳送sms/mms 

1. //

呼叫簡訊程式

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

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

4. it.settype("vnd.android-dir/mms-sms");   

5. startactivity(it);  

1. //

傳送訊息

2. uri uri = uri.parse("smsto://0800000123");   

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

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

5. startactivity(it);  

1. //

傳送mms   

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

3. intent it = new intent(intent.action_send);    

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

5. it.putextra(intent.extra_stream, uri);   

6. it.settype("image/png");    

7. startactivity(it);   

傳送email 

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

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

3. startactivity(it);   

1. intent it = new intent(intent.action_send);   

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

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

4. it.settype("text/plain");   

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

1. intent it=new intent(intent.action_send);     

2. string tos=;     

3. string ccs=;     

4. it.putextra(intent.extra_email, tos);     

5. it.putextra(intent.extra_cc, ccs);     

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

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

8. it.settype("message/rfc822");     

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

1. //

傳送附件

2. intent it = new intent(intent.action_send);   

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

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

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

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

startactivity(it);

Intent的幾種用法

returnit new intent intent.action delete,uninstalluri install apk uri installuri uri.fromparts package null returnit new intent intent.action package ...

Intent的幾種用法

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

Intent的幾種用法

下面列出幾種intent的用法 顯示網頁 uri uri uri.parse intent it new intent intent.action view,uri startactivity it 顯示地圖 uri uri uri.parse geo 38.899533,77.036476 int...