android - How to call contact picker from home screen? -


i'm experimenting creating custom android home screen. i've used sample home screen application , have adapted it. do, open contact picker button in home screen , use contact user chose in next action. i've stumbled on same problem mentioned in this question.

how can work around home screen stays "singleinstance" , can call startactivityforresult()?

is contacts picker activity can subclass (i've searched can't find any) can use solution david wasser proposes in aforementioned question?

i've found elegant solution after all:

my main activity launches intermediate, invisible activity has android:theme="@android:style/theme.nodisplay"

this intermediate activity calls contact picker in oncreate

intent phonecontactintent = new intent(intent.action_pick,      contactscontract.contacts.content_uri); // show user contacts w/ phone numbers phonecontactintent.settype(phone.content_type);  startactivityforresult(phonecontactintent, choose_contact_to_call); 

then, in onactivityresult, creates new intent main application, data contact picker returned.

    switch (requestcode) {     case (choose_contact_to_call):         if (resultcode == activity.result_ok) {             intent resultintent = new intent(this, home.class);             resultintent.putextras(data);              uri contactdata = data.getdata();             if (contactdata != null)             {                 resultintent.setdata(contactdata);             }             startactivity(resultintent);         }     }     finish(); 

and in home class, in oncreate call getintent() , inspect data in intent launched main activity.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -