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. [WTI] Gtab upgrade 2.3.3

Di samcen udah rilis belum ya?



-- 
"

2. help with new class declaration

I added a new class to my Android project and then declared it in my
main .java file like this:

Encounter EncounterGenerator;

However, I'm getting this error:

"Encounter cannot be resolved to a type"

My new class is in a separate file with the code listed below.

Is there anything I'm doing wrong?

Thanks!

package myStuff.HelloAndroid;

public class EncounterGenerator {

        public String EncounterGenerator() {
                String encounterText;
                int encounter;
                encounter = (int)(Math.random() * 3);

                switch (encounter) {
                case 0:  encounterText = "Encounter # 1";
                                 break;
                case 1:  encounterText = "Encounter # 2";
                                 break;
                case 2:  encounterText = "Encounter # 3";
                                 break;
                default: encounterText = "Encounter # 4";
                }
                return encounterText;
        }
}

-- 

3. Android (GingerBread) compliance with AT&T requirements

4. Android: how to draw an ImageView with the same size regardless of device?

5. help with TextView

6. On CRC32, LVL and tamper-proof app

7. How to use Notification service from Broadcast receiver