Reputation: 43
I'm trying to link one of my buttons to an intent that will open up the contacts application on my device. Any help with how to use an intent or other method to open it up?
public class MainActivity extends Activity implements View.OnClickListener {
View v;
Button contacts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getContacts();
contacts.setOnClickListener(this);
}
private void getContacts() {
// TODO Auto-generated method stub
contacts = (Button) findViewById(R.id.bcontacts);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.bcontacts:
intent contacts = new Intent \\this is where i dont know what to do
break;
}
}
}
Upvotes: 4
Views: 688
Reputation: 17037
That should do the trick for you :
Intent intent= new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
Upvotes: 1