I am trying to make an app that, when a button is pressed, the contact list is pulled up, and when a contact is selected, it opens the contact for viewing. 目前,我可以拉出联系人列表,但是一旦我选择了姓名,它就会返回按钮屏幕。这里有什么帮助吗?这是我的代码
public class TestStuff extends Activity implements OnClickListener{
private static final int PICK_CONTACT = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button contacts = (Button) findViewById(R.id.bContacts);
contacts.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
}