简体   繁体   English

当用户从“联系人”的“完成操作使用”菜单中选择我的应用程序时,如何联系

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

I am writing auto dialer. 我正在写自动拨号器。 My main activity has an edittext to enter the telephone no or retrieve from contacts when they click "Add from Contacts". 我的主要活动有一个edittext,用于输入电话号码或在点击“从联系人添加”时从联系人中检索。 It is working fine. 它工作正常。

Now, my requirement is that I need to add my app into Contact's Complete Action Using menu. 现在,我的要求是我需要将我的应用程序添加到Contact的Complete Action Using菜单中。

It is also done. 它也完成了。 But when user choose my app from complete action using menu, I want that selected phone no and set the phone no. 但是当用户使用菜单从完整操作中选择我的应用程序时,我希望选择的手机没有,并设置手机号码。 on my main screen. 在我的主屏幕上。

Now only my app is opened and phone no. 现在只有我的应用程序打开,电话号码。 is black. 是黑色的。

I would like to know how to get that selected phone no. 我想知道如何获得所选手机号码。 when they start my app from contacts. 当他们从联系人开始我的应用程序。

Here is my answer for my question. 这是我对我的问题的回答。

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.

相关问题 从“使用(短信应用程序)完成操作”屏幕启动应用程序时,如何获取联系人号码和姓名? - How do I get Contact number + name when app is launched from 'complete action using (sms app)' screen? 当用户选择一首歌曲>使用对话框完成动作>在我的应用中时,如何获取歌曲详细信息 - how can i get song details, when user chooses a song>complete action using dialog> into my app 当用户单击我网站上的 html 按钮时,如何将联系人保存到 Android/IOS 电话簿(联系人应用程序) - How to save a contact to Android/IOS phone book (contacts app) when a user clicks an html button on my website 如何从Android的联系人列表中获取联系人? 使用联系提供者 - How to get contacts from contact list in Android? using Contact Provider 单击TextView时如何从我的应用程序中删除“使用完成操作”窗口? - how remove “complete action using” window from my app when click on TextView ?? 将我的应用程序图标附加到默认的“联系人”应用程序的“快速操作”菜单 - Attach my app's icon to default Contacts app's Quick Action menu 联系人应用程序中未显示联系人-使用示例联系人管理器应用程序时 - Contacts not shown in contacts app - when using sample contact manager application 如何从Android中的联系人获取联系人号码? - how to get the contact number from contacts in android? 如何将我的 Flutter 应用程序联系人链接到 android 的本机联系人应用程序? - How to link my Flutter App contacts to android's native contact application? 如何在Android上将“选择动作”更改为“使用完成动作”? - How to change “Choose an action” to “Complete action using” on Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM