簡體   English   中英

當用戶從“聯系人”的“完成操作使用”菜單中選擇我的應用程序時,如何聯系

[英]How to get contact when user choose my app from Contacts's Complete Action Using menu

我正在寫自動撥號器。 我的主要活動有一個edittext,用於輸入電話號碼或在點擊“從聯系人添加”時從聯系人中檢索。 它工作正常。

現在,我的要求是我需要將我的應用程序添加到Contact的Complete Action Using菜單中。

它也完成了。 但是當用戶使用菜單從完整操作中選擇我的應用程序時,我希望選擇的手機沒有,並設置手機號碼。 在我的主屏幕上。

現在只有我的應用程序打開,電話號碼。 是黑色的。

我想知道如何獲得所選手機號碼。 當他們從聯系人開始我的應用程序。

這是我對我的問題的回答。

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    Intent intent = getIntent();
    String action = intent.getAction();
    if(action != null){

        // Set the user selected phone number when action lunch directly
        // from
        // contacts
        if (action.equalsIgnoreCase(INTENT_CALL_PRIVILEGED)) {
            setCallPrivilegedData();
        }
    }
    setCardSpinner();

}

private void setCallPrivilegedData() {
    phoneNumber = getIntent().getDataString();
    EditText phoneNoEditText = (EditText) findViewById(R.id.phone_no);
    try {
        phoneNoEditText.setText(URLDecoder.decode(phoneNumber.substring(4),
                "utf-8"));
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM