woong's

Android 다이얼 or 전화걸기 본문

Develop/Android

Android 다이얼 or 전화걸기

dlsdnd345 2016. 2. 14. 13:00
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Android  다이얼 or 전화걸기 


​안녕하세요.  

android 에서 전화 걸기 기능을 이용하기 위해서는 퍼미션을 획득 해야 합니다 .


Colored By Color Scripter

1
2
    <!-- 전화 걸기 -->
    <uses-permission android:name="android.permission.CALL_PHONE" />

 

 

​아래 퍼미션을 등록 합니다 . 


등록후,

 

Colored By Color Scripter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.handstudio.android.vo;
 
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
 
public class Call {
 
    public static final String TELL_FORMAT = "tel:";
    
    public static final String DIAL = "dial";
    public static final String DIRECT_CALL = "directCall";
    
    private Context context;
    
    public Call(Context context){
        this.context = context;
    }
    
    /**
     * 전화 걸기 기능
     * 전화 다이얼 표시/전화 바로 걸기 기능
     * callType (dial/directCall)
     * @param callType
     */
    public void makeACall(String callType , String phoneNumber){
        
        Intent intent = null;
        
        if(callType.equals(DIAL)){//dial
              intent = new Intent(Intent.ACTION_DIAL, Uri.parse(TELL_FORMAT+phoneNumber));
        }else{//directCall
              intent = new Intent(Intent.ACTION_CALL, Uri.parse(TELL_FORMAT+phoneNumber));
        }
          context.startActivity(intent);
    }
    
}
 

 

 

하단의 메서드를 이용 하면 됩니다 .

굉장히 간단합니다 .Intent 를 통해서 전화번호를 넘겨 주면 됩니다 .


여기서 주의 점은 


전화번호 넘기는 형식이


"tel:010-1234-1234"


형식을 맞추어주어야 합니다.


Comments