android - Store contacts' name and phones into an ArrayList -


i cannot make solution work... result app crash. made listview, added items , got selected ones, miss making elements of list contacts' names instead of random ones.

once selected, ask number , putextra them in activity.

edit: suggested, here's code i'm trying working:

            cursor phones = getcontentresolver().query(contactscontract.commondatakinds.phone.content_uri, null,null,null, null);         while (phones.movetonext())         {             string name=phones.getstring(phones.getcolumnindex(contactscontract.commondatakinds.phone.display_name));             string phonenumber = phones.getstring(phones.getcolumnindex(contactscontract.commondatakinds.phone.number));          }         phones.close(); 

i'll insert loop every contact, adding every time strings name , phonenumber arraylist. however, when press button should run code (and button working fine), long list of errors android monitor (here's first lines):

e/androidruntime: fatal exception: main java.lang.illegalstateexception: not execute method android:onclick @ android.support.v7.app.appcompatviewinflater$declaredonclicklistener.onclick(appcompatviewinflater.java:293) 

i've added permission manifest:

    <uses-permission android:name="android.permission.read_contacts" /> 

could please me? thanks!

p.s. i've tryed multiple solutions this previus topic, none of them work me...

solved


it app permission's issue. android 6.0 marshmallow have ask permissions directly in java code (during oncreate method); later i'll post sample code.


big friend blitzuda helped bug out of problem!


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -