I am writting my application using api 1.6. The code runs just fine on the emulators 1.6-2.2.
But when I try to debugging it on my device which runs 2.1 data.getData()
returns null. I have this in the AndroidManifest.xml <uses-permission android:name="android.permission.READ_CONTACTS"/>
Any one have any thoughts. I am new to android, thanks.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnTest = (Button) findViewById(R.id.btnTest);
btnTest.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
startActivityForResult(intent, ACTIVITY_PICK_CONTACT);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case (ACTIVITY_PICK_CONTACT):
if (resultCode == Activity.RESULT_OK) {
// This is where it is broke
Uri uri = data.getData();
Intent intent = new Intent(this, PickContactInfo.class);
intent.putExtra(Keys.CONTACT_URI, uri.toString());
startActivity(intent);
}
break;
}
};