Need Help in Listview need to fetch Contacts

by nubh bhargava » Mon, 05 Apr 2010 15:18:16 GMT


Sponsored Links
 Hi

I am very new to android, I am working on CupCake or version 1.5 and need to
import contact list with phone no and name into a new list. can anyone
please suggest me what to do.

Thanks in Advance
NUBH

--



Need Help in Listview need to fetch Contacts

by Justin Anderson » Mon, 05 Apr 2010 21:34:34 GMT


 I've never done this but you need to use a content provider...  I think you
want to look at the ContactsContract class




Hi

I am very new to android, I am working on CupCake or version 1.5 and need to
import contact list with phone no and name into a new list. can anyone
please suggest me what to do.

Thanks in Advance
NUBH

--


Sponsored Links


Need Help in Listview need to fetch Contacts

by nubh bhargava » Tue, 06 Apr 2010 12:52:22 GMT


 The problem is ContactsContract class only supports level 5 and after I
looked onto it.
Thanks
NUBH

--



Need Help in Listview need to fetch Contacts

by Justin Anderson » Tue, 06 Apr 2010 13:10:15 GMT


 Ok well, then you will want to use the deprecated version of that.  I don't
know what it is but I'm sure if you Google something like "Android 1.5
Contacts Content Provider" (or something similar) then you should get
something...


----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------





>



Need Help in Listview need to fetch Contacts

by nubh bhargava » Tue, 06 Apr 2010 13:19:48 GMT


 Ya, exactly please see the code I need to fetch something in the adapter
area but do not understand how to do it, please help.

*

package* com.example.HelloSpinner;

*

import* android.app.Activity;
*

import* android.content.ContentUris;
*

import* android.content.Intent;
*

import* android.database.Cursor;
*

import* android.os.Bundle;
*

import* android.provider.Contacts.People;
*

import* android.provider.Contacts.Phones;
*

import* android.view.View;
*

import* android.widget.AdapterView;
*

import* android.widget.SimpleCursorAdapter;
*

import* android.widget.Spinner;
*

import* android.widget.Toast;
*

import* android.widget.AdapterView.OnItemSelectedListener;

*

public* *class* HelloSpinner *extends* Activity

{

*public* *void* onCreate(Bundle savedInstanceState)

{

*super*.onCreate(savedInstanceState);

setContentView(R.layout.*main*);

String[] *PROJECTION* = *new* String[]

{

People.*_ID*, People.*NAME
*

};

Spinner spinner = (Spinner) findViewById(R.id.*spinner*);

spinner.setOnItemSelectedListener(*new* MyOnItemSelectedListener());

Cursor cur = getContentResolver().query(People.*CONTENT_URI*, *null*, *null*,
*null*, *null*);

SimpleCursorAdapter adapter2 = *new* SimpleCursorAdapter(*this*,

android.R.layout.*simple_spinner_item*,

// Use a template

// that displays a

// text view

cur,

// Give the cursor to the list adapter

*new* String[] {People.*NAME*},

// Map the NAME column in the

// people database to...

*new* *int*[] {android.R.id.*text1*});

// The "text1" view defined in

// the XML template

adapter2.setDropDownViewResource(android.R.layout.*
simple_spinner_dropdown_item*);

spinner.setAdapter(adapter2);

 } // The create method ends

*public* *class* MyOnItemSelectedListener *implements*OnItemSelectedListener

{

*public* *void* onItemSelected(AdapterView<?> parent,

View view, *int* pos, *long* id)

{

Intent intent = *new* Intent(Intent.*ACTION_CALL*);

Cursor cursor = *(Cursor) AdapterView.*;

*long* phoneId = cursor.getLong(cursor.getColumnIndex(People.*
PRIMARY_PHONE_ID*));

intent.setData(ContentUris.*withAppendedId*(Phones.*CONTENT_URI*, phoneId));

startActivity(intent);

Toast.*makeText*(parent.getContext(),

"The Person is " +

parent.getItemAtPosition(pos).toString(),

Toast.*LENGTH_LONG*).show();

}

*public* *void* onNothingSelected(AdapterView<?> parent)

{

// Do nothing.

}

}

}

--



Need Help in Listview need to fetch Contacts

by nubh bhargava » Tue, 06 Apr 2010 13:21:26 GMT


 The problem is on the underlined text, just check.

Thanks & Regards
NUBH

--



Other Threads

1. Content provider example besides Contacts.

Hi there. I'm trying to develop a simple APN changer. I checked the
tutorials and the CP are basicaly some sql databases accesed with a
pointer. The thing is, for example, that the APN value seems to be in
the settings DB? I dont find a clear reference to that in the API nor
i can access it using the technique shown in the Contacts tutorial.

Some lines of code to illustrate how to access the APN info me would
be really apreciated! Sorry if this is terrible newbish, but cant find
a simple non contact based tutorial regarding CPs.

-- 

2. Fabook! App Facebook chat

Real android Facebook chat application!...kekekekekekeke...

Paid app...u know jalan ke pasar malam?

Hajaaaaaaar...

-- 
"Indonesian Android Community [id-android]" 

3. Produk baru motorola with big vibrate menu

4. How can I remove an item from ExpandableListView or how can I reload an single group from ExpandableListView?

5. Bluetooth RFCOMM connection dying immediately after .connect()

6. Perbedaan Android dan iPhone

7. Reading "Name (phonetic)" field on Eclair