【问题标题】:How do I open the default contacts screen on Android? [closed]如何在 Android 上打开默认联系人屏幕? [关闭]
【发布时间】:2013-07-05 06:04:39
【问题描述】:

如何在 Android 上打开默认联系人屏幕?

【问题讨论】:

标签: android


【解决方案1】:

大家好,欢迎来到 StackOverflow 和 Android 开发。

为了打开联系人屏幕,您需要为您的按钮捕获OnClick 事件并创建打开联系人屏幕的意图。

类似这样的:

Button myButton = (Button) myLayout.findViewById(R.id.myButton);
myButton..setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent= new Intent(Intent.ACTION_PICK,  Contacts.CONTENT_URI);
            startActivity(intent);
        }
    });

如果您想对用户选择的联系人执行某些操作,请改用 startActivityForResult 并覆盖 onActivityResult 方法(阅读有关 here 的更多信息。

herehere可以找到一些类似的答案!

祝你好运!

【讨论】:

  • 为什么是 ACTION_PICK 而不是 ACTION_VIEW?
【解决方案2】:

代码

Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse("content://contacts/people/"));
startActivity(i);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    • 2019-11-20
    相关资源
    最近更新 更多