미채택 완료

PC에서 BOOK마크저장과 같이 모바일에서 클릭으로 핸드폰번호를 연락처에 저장할수있을까요?

2017-06-14 (수) 21:21:17 6,253

내용 그대로 입니다~~!

PC에선 북마크버튼을 누르면 북마크에 저장되잖아요~

근데 모바일 화면에서 버튼을 누르면 휴대폰 번호가 상대방의 연락처에 저장되게 할 방법이

있을까요?

답변 2개 / 댓글 4개

       public static final int PICK_CONTACT    = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // this opens the activity. note the  Intent.ACTION_GET_CONTENT
        // and the intent.setType
        ((Button)findViewById(R.id.btn_contacts)).setOnClickListener( new OnClickListener() {
            @Override
            public void onClick(View v) {
                // user BoD suggests using Intent.ACTION_PICK instead of .ACTION_GET_CONTENT to avoid the chooser
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                // BoD con't: CONTENT_TYPE instead of CONTENT_ITEM_TYPE
                intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
                startActivityForResult(intent, 1);                
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (data != null) {
            Uri uri = data.getData();

            if (uri != null) {
                Cursor c = null;
                try {
                    c = getContentResolver().query(uri, new 
2017-06-14 (수) 21:23:41

연락처 <a href="tel:전화번호">전화번호나 버튼이미지</a>

위처럼 http://대신에 tel:해놓으시면 휴대폰에서 전화번호를 누르면 통화를 할건지 저장을 할건지 뜹니다.

sms:하시면 문자전송이 될겁니다. 이건 제가 써보질 않아서요.

답변에 대한 댓글 4개

ㅠ,ㅠ..
저장할때 양식이 비어나와서 ㅠㅠ...
북마크처럼 제목이 살아서 보여야하는데
방법이 없을까요~?
2017-06-14 (수) 21:41:20
저의 한계입니다 ㅋㅋ
$data = '+11234567890';

if( preg_match( '/^\+\d(\d{3})(\d{3})(\d{4})$/', $data, $matches ) )
{
$result = $matches[1] . '-' .$matches[2] . '-' . $matches[3];
return $result;
}

서핑해서 갖고온 소스인데 이걸로 하면 될까요??ㅎㅎ
2017-06-14 (수) 23:00:11
-.-;;; 머리가;; 아....프....

답변을 작성하려면 로그인이 필요합니다.