2016-06-22 3 views
0

私は連絡先を選ぶために連絡先選択の意図を使用したいと思います。また、自分の活動に連絡先を追加する機能も必要です。連絡先を追加するつもりがあります。あなたがアンドロイドの連絡先アプリで使用されているように、この両方を一緒に使用できるかどうか知りたいナットですか?このようコンタクトピッカーでコンタクト意図を追加できますか?

enter image description here

我々は連絡先ピッカーを使用するだけでなく、接触の意図を追加することはできますか?

答えて

0

ACTION_PICKは、連絡先を選択できるようになります..あなたに感謝。ただし、連絡先選択ツールのUIに連絡先オプションを追加するように要求する方法はありません。さらに、接触ピッカーUIがにさえ、のアド・コンタクトオプションを持つ必要はありません。

ユーザーが連絡先を追加できるようにしたい場合は、独自のUIトリガACTION_INSERTまたはACTION_INSERT_OR_EDIT活性を有する:

/*** 
    Copyright (c) 2008-2012 CommonsWare, LLC 
    Licensed under the Apache License, Version 2.0 (the "License"); you may not 
    use this file except in compliance with the License. You may obtain a copy 
    of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required 
    by applicable law or agreed to in writing, software distributed under the 
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
    OF ANY KIND, either express or implied. See the License for the specific 
    language governing permissions and limitations under the License. 

    From _The Busy Coder's Guide to Android Development_ 
    https://commonsware.com/Android 
*/ 

package com.commonsware.android.inserter; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.provider.ContactsContract.Contacts; 
import android.provider.ContactsContract.Intents.Insert; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 

public class ContactsInserter extends Activity { 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    Button btn=(Button)findViewById(R.id.insert); 

    btn.setOnClickListener(onInsert); 
    } 

    View.OnClickListener onInsert=new View.OnClickListener() { 
    public void onClick(View v) { 
     EditText fld=(EditText)findViewById(R.id.name); 
     String name=fld.getText().toString(); 

     fld=(EditText)findViewById(R.id.phone); 

     String phone=fld.getText().toString(); 
     Intent i=new Intent(Intent.ACTION_INSERT_OR_EDIT); 

     i.setType(Contacts.CONTENT_ITEM_TYPE); 
     i.putExtra(Insert.NAME, name); 
     i.putExtra(Insert.PHONE, phone); 
     startActivity(i); 
    } 
    }; 
} 

this old sample projectから)

関連する問題