1. 程式人生 > >Android開發之Intent跳轉到系統應用中的撥號介面、聯絡人介面、簡訊介面

Android開發之Intent跳轉到系統應用中的撥號介面、聯絡人介面、簡訊介面

現在開發中的功能需要直接跳轉到撥號、聯絡人、簡訊介面等等,查找了很多資料,自己整理了一下。
         首先,我們先看撥號介面,程式碼如下:

  1. Intent intent =new Intent();  
     
  2.             intent.setAction("android.intent.action.CALL_BUTTON");  
     
  3.             startActivity(intent);
複製程式碼

  1. Uri uri = Uri.parse("tel:xxxxxx");   
     
  2. Intent intent = new Intent(Intent.ACTION_DIAL, uri);     
     
  3. startActivity(intent);  
複製程式碼

兩者都行   
但是如果是跳轉到應用,使用一下程式碼:

  1. Intent intent= new Intent("android.intent.action.DIAL");   
     
  2. intent.setClassName("com.android.contacts","com.android.contacts.DialtactsActivity");
複製程式碼

到通話記錄介面:

  1. Intent intent=new Intent();  
     
  2. intent.setAction(Intent.ACTION_CALL_BUTTON);  
     
  3. startActivity(intent);  
複製程式碼

到聯絡人介面:

  1. Intent intent = new Intent();   
     
  2. intent.setAction(Intent.ACTION_VIEW);   
     
  3. intent.setData(Contacts.People.CONTENT_URI);   
     
  4. startActivity(intent);
複製程式碼

同理,到應用:

  1. Intent intent= new Intent("com.android.contacts.action.LIST_STREQUENT");   
     
  2. intent.setClassName("com.android.contacts","com.android.contacts.DialtactsActivity");
複製程式碼

呼叫聯絡人介面:

  1. Intent intent = new Intent();   
     
  2. intent.setAction(Intent.ACTION_PICK);   
     
  3. intent.setData(Contacts.People.CONTENT_URI);   
     
  4. startActivity(intent);   
複製程式碼

插入聯絡人

  1. Intent intent=new Intent(Intent.ACTION_EDIT,Uri.parse("content://com.android.contacts/contacts/"+"1"));  
     
  2. startActivity(intent);  
複製程式碼

到聯絡人列表介面   

  1. Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);  
     
  2.             intent.setType("vnd.android.cursor.item/person");  
     
  3.             intent.setType("vnd.android.cursor.item/contact");  
     
  4.             intent.setType("vnd.android.cursor.item/raw_contact");  
     
  5.             intent.putExtra(android.provider.ContactsContract.Intents.Insert.NAME, name);  
     
  6.             intent.putExtra(android.provider.ContactsContract.Intents.Insert.COMPANY,company);  
     
  7.             intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, tel);  
     
  8.             intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE_TYPE, 3);
複製程式碼

到簡訊介面:

  1. Intent intent = new Intent(Intent.ACTION_VIEW);  
     
  2.                 intent.setType("vnd.android-dir/mms-sms");  
     
  3. //              intent.setData(Uri.parse("content://mms-sms/conversations/"));//此為號碼  
     
  4.                 startActivity(intent);  
複製程式碼

到應用:

  1. Intent intent = new Intent("android.intent.action.CONVERSATION");  
     
  2. startActivity(intent);  
複製程式碼

以下是在網上找到的其他方法:


1.從google搜尋內容

  1. Intent intent = new Intent();   
     
  2. intent.setAction(Intent.ACTION_WEB_SEARCH);   
     
  3. intent.putExtra(SearchManager.QUERY,"searchString")   
     
  4. startActivity(intent);   
複製程式碼

2.瀏覽網頁

  1. Uri uri = Uri.parse("http://www.google.com");   
     
  2. Intent it   = new Intent(Intent.ACTION_VIEW,uri);   
     
  3. startActivity(it);
複製程式碼

3.顯示地圖

  1. Uri uri = Uri.parse("geo:38.899533,-77.036476");   
     
  2. Intent it = new Intent(Intent.Action_VIEW,uri);   
     
  3. startActivity(it);   
複製程式碼

4.路徑規劃

  1. Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");   
     
  2. Intent it = new Intent(Intent.ACTION_VIEW,URI);   
     
  3. startActivity(it);  
複製程式碼

5.撥打電話

  1. Uri uri = Uri.parse("tel:xxxxxx");   
     
  2. Intent it = new Intent(Intent.ACTION_DIAL, uri);     
     
  3. startActivity(it);  
複製程式碼

  1. uri = Uri.parse("tel:"+number);    
     
  2.                 intent = new Intent(Intent.ACTION_CALL,uri);    
     
  3.                 startActivity(intent);  
複製程式碼

其中不同自己試驗一下就知道了。 

6.呼叫發簡訊的程式

  1. Intent it = new Intent(Intent.ACTION_VIEW);     
     
  2. it.putExtra("sms_body", "The SMS text");     
     
  3. it.setType("vnd.android-dir/mms-sms");     
     
  4. startActivity(it);
複製程式碼

  1. uri = Uri.parse("smsto:"+要傳送簡訊的對方的number);    
     
  2.                 intent = new Intent(Intent.ACTION_SENDTO,uri);    
     
  3.                 startActivity(intent);   
複製程式碼

  1. mIntent = new Intent(Intent.ACTION_VIEW);    
     
  2.         mIntent.putExtra("address", c.getString(c.getColumnIndex(column)));    
     
  3.         mIntent.setType("vnd.android-dir/mms-sms");    
     
  4.         startActivity(mIntent);   
複製程式碼

7.傳送簡訊

  1. Uri uri = Uri.parse("smsto:0800000123");     
     
  2. Intent it = new Intent(Intent.ACTION_SENDTO, uri);     
     
  3. it.putExtra("sms_body", "The SMS text");     
     
  4. startActivity(it);   
     
  5. String body="this is sms demo";   
     
  6. Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", number, null));   
     
  7. mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);   
     
  8. mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true);   
     
  9. mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true);   
     
  10. startActivity(mmsintent);<span style="font-family:Simsun;white-space: normal; background-color: rgb(255, 255, 255);"> </span>  
複製程式碼

8.傳送彩信

  1. Uri uri = Uri.parse("content://media/external/images/media/23");     
     
  2. Intent it = new Intent(Intent.ACTION_SEND);     
     
  3. it.putExtra("sms_body", "some text");     
     
  4. it.putExtra(Intent.EXTRA_STREAM, uri);     
     
  5. it.setType("image/png");     
     
  6. startActivity(it);   
     
  7. StringBuilder sb = new StringBuilder();   
     
  8. sb.append("file://");   
     
  9. sb.append(fd.getAbsoluteFile());   
     
  10. Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null));   
     
  11. // Below extra datas are all optional.   
     
  12. intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject);   
     
  13. intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);   
     
  14. intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString());   
     
  15. intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode);   
     
  16. intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent);   
     
  17. startActivity(intent);   
複製程式碼

9.傳送Email

  1. Uri uri = Uri.parse("mailto:[email protected]");   
     
  2. Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
     
  3. startActivity(it);   
     
  4. Intent it = new Intent(Intent.ACTION_SEND);     
     
  5. it.putExtra(Intent.EXTRA_EMAIL, "[email protected]");     
     
  6. it.putExtra(Intent.EXTRA_TEXT, "The email body text");     
     
  7. it.setType("text/plain");     
     
  8. startActivity(Intent.createChooser(it, "Choose Email Client"));   
     
  9. Intent it=new Intent(Intent.ACTION_SEND);       
     
  10. String[] tos={"[email protected]"};       
     
  11. String[] ccs={"[email protected]"};       
     
  12. it.putExtra(Intent.EXTRA_EMAIL, tos);       

    相關推薦

    Android開發Intent系統應用撥號介面聯絡人介面簡訊介面

    現在開發中的功能需要直接跳轉到撥號、聯絡人、簡訊介面等等,查找了很多資料,自己整理了一下。          首先,我們先看撥號介面,程式碼如下: Intent intent =new Intent();                 intent.setAction("an

    Android開發Activity動畫以及finish動畫

    Android預設的activity跳轉是不帶動畫的,但是如果想要動畫的話是有兩種方法的,一種是程式碼中加入,另外一種是寫在佈局中的theme中的 第一種: 程式碼中加入,在startActivity或者finish之後加入 ps:inAnimRe

    Android系統應用

    收集的一些關於android系統級別的跳轉 跳轉到視訊列表 String VIDEO_UNSPECIFIED="video/*"; Intent intent=new Intent(Intent.ACTION_GET_CONTENT); intent.setType(VIDEO_

    6.Android的學習(Intent頁面,活動之間傳遞資料)

    Intent跳轉頁面 (1)使用顯示Intent,首先建立一個空的活動,並且有佈局,在onClick()下面新增: Intent裡面的第一個引數是當前活動頁面,第二引數是要跳轉的活動頁面。這段程式碼在當前活動頁面。 2.  (1)向下一個活動傳遞資料  · 主活動介

    Android開發Intent.Action 各種Action的常見作用

    //拍攝視訊 int durationLimit = getVideoCaptureDurationLimit(); //SystemProperties.getInt("ro.media.enc.lprof.duration", 60);Intent intent = new Intent(MediaS

    Android開發實現連續幾個介面後在最後一個介面完美回最初的介面

     在實際的專案開發中也許會碰到一種情況,需要從A介面跳轉到B介面,再從B介面跳轉到C介面,再從C介面跳轉到D介面,最後需要從D介面跳回到A介面,並且把B、C 、D介面都幹掉。也許立馬會有人覺得可以在B、C、D介面跳轉時就finish()掉當前介面就可以了。但是如果需要在B

    Android開發listView使用(手機應用列表顯示)

    public class MainActivity extends Activity implements OnItemLongClickListener { private ListView lv_main; private List<AppInfo> data; private App

    android開發fragment與activity之間相互

       Fragment的產生與介紹 Android執行在各種各樣的裝置中,有小螢幕的手機,超大屏的平板甚至電視。針對螢幕尺寸的差距,很多情況下,都是先針對手機開發一套App,然後拷貝一份,修改佈局以適應平板神馬超級大屏的。難道無法做到一個App可以同時適應手機和平板麼

    Android開發Activity的建立及傳值

    在Android系統的江湖中有四大元件:活動(Activity), 服務(Service), 廣播接收器(Broadcast Reciver)和內容提供者(Content Provider)。今天所介紹的就是Android開發中的四大元件之一:Activity,其他那三大元件

    Android開發實現蘋果瀏覽器網頁動畫

    前言:上一章《Android開發之安卓屬性動畫大總結》大致介紹了安卓的屬性動畫以及使用時的注意點,今天我們就來一個小綜合案列,實現類似於蘋果瀏覽器的跳轉頁面! ----------------------分割線------------------------ 來看下效果圖:

    Android開發--從app到淘寶店鋪

    首先、一個工具類   方法,檢測該包名下的應用是否存在 public static boolean checkPackage(Context context ,String packageName) { if (packageName == null || "".

    Android開發增量更新

    avt exp chm 這一 font ams extern city ron 一、使用場景 apk升級,節省服務器和用戶的流量 二、原理 自從 Android 4.1 開始, Google Play 引入了應用程序的增量更新功能,App使用該升級方式,可節省約2/3

    Android 系統選擇本地視頻的功能

    選擇 打開文件 result 打開圖片 provide ati 迷你 nal 名稱   今天在項目開發的過程中產品要求添加選擇本地視頻的功能,於是就翻閱和查找各種資料,進行功能的開發,但是在開發過程中發現,各種不同的品牌的手機跳轉至系統選擇本地視頻的功能結果不太一樣,所以我

    android入門開發Intent學習

    Intent的四種開啟方式(顯示開啟): //顯示intent第一種方式 Intent intent = new Intent(); intent.setClass(this, Activity_one.class);   start

    android 開發 ListView 與Adapter 應用實踐

    在開發android中,ListView 的應用顯得非常頻繁,只要需要顯示列表展示的應用,可以說是必不可少,下面是記錄開發中應用到ListView與Adapter 使用的例項: ListView 所在頁面中的佈局(listview_item.xml): <?xml version="1.0"

    安卓開發傳送簡訊的方法 APP內單發簡訊 群發簡訊 APP簡訊頁 單條簡訊 多條簡訊Intent

    1.APP內部直接傳送短息 包括髮送單條簡訊 傳送多條簡訊 APP內部發送簡訊首先要獲取一個傳送簡訊的許可權 <uses-permission android:name="android.permission.SEND_SMS"/> 安卓6.0以上的手機要動態獲取到這個許可

    Android系統設定Settings的各個介面

    系統定義的常量 有時候需要跳轉到一些系統設定介面,為了方便尋找總結一下 定義Intent 相關介面 ACTION_SETTINGS 系統設定介面 ACTION

    Android開發應用狀態列導航欄都透明

      直接上程式碼 //狀態列、導航欄都透明 private void hideStatusBarNavigationBar() { if (Build.VERSION.SDK_INT = Build.VERSION_CODES.LOLLIPOP)

    Android開發系統音訊庫載入全過程

    本文基於android7.0分析 在介紹解析音訊配置檔案文章中 已經說了,系統音訊庫的載入與否取決audio_policy.conf是否有配置其資訊。 當將audio_policy.conf解析完成之後,接下來就是根據解析好的配置檔案資料去載入系統音訊庫,我們繼續看到 

    Android系統通知許可權設定

      測試過華為、小米、魅族跳轉下列程式碼可以支援 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Intent intent = new Intent();