views:

103

answers:

1

So I can display Android's contact selecton activity by calling

startActivityForResult(intent, PICK_CONTACT); 

and i can get the selected contact by overriding onActivityResult

public void onActivityResult(int reqCode, int resultCode, Intent data) { 
  super.onActivityResult(reqCode, resultCode, data); 
}

Trouble is onActivityResult is only available when I am calling from an Activity myself. If I am in a DialogPreference for instance how would i get at the selected contact because I do not have an onActivityResult to override ?

TIA

Pat Long

A: 

I know you want to create a custom DialogPreference to Pick a Contact as proposed in the other question, you indeed need to launch the intent to pick the contact and get the result.

I see you need to create a private class that extends Activity in your own DialogPreference class. And you will use that class and the onActivityResult.

You are doing a great job, keep up the good work.

Pentium10
OK So I have had some time today to take a look at this and am getting a NullPointerException after firing "startActivityForResult(intent, PICK_CONTACT);" Just want to run by you my approach New class ContactPreference extends Preference. New class PickContactActivity extends Activity ContactPreference adds a button to its layout, when clicked that calls a method on a PickContactActivity instance. The method in PickContactActivity calls startActivityForResult(intent, PICK_CONTACT); This call fails with NullPointerException. Is that approach what you might expect?
Pat Long - Munkii Yebee
Can you figure out what is null at that time, probably your intent or something else?
Pentium10
Already checked, nothing obvious. The intent that is gettign past tostartActivityForResult looks like this in Eclipse "Intent { act=android.intent.action.PICK dat=content://contacts/people }"The call stack is reporting line 2661 in startActivityForResult
Pat Long - Munkii Yebee