N
N
networkview2014-02-02 17:02:28
Android
networkview, 2014-02-02 17:02:28

How to get contact numbers in Android?

package com.example.app;
 
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
 
import android.provider.ContactsContract;
import android.widget.SimpleCursorAdapter;
 
 
public class MainActivity extends ListActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Cursor cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI, null, null, null, ContactsContract.Contacts.HAS_PHONE_NUMBER);
        String[] contacts = new  String[]{String.valueOf(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))))};
        int[] ints = new  int[]{android.R.id.text1};
        SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(this,android.R.layout.simple_list_item_1,cursor,contacts,ints);
        this.setListAdapter(simpleCursorAdapter);
    }
 
}
<code lang="java">

Подскажите, что я делаю не так?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
constv, 2014-02-03
@constv

here is an example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question