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. Oot,testing

QWERTY 123456

Jus
~ using windows mobile 2003 ~

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

2. ADT Problem: Creating new Android Project

This drop down list is populated by Eclipse automatically, using the list  
of installed Android platform versions.


Did you install any Android platform SDKs?

If not, see here:

http://developer.android.com/sdk/installing.html#components

... "You need to download at least one platform into your environment, so that you will be able to compile your application and set up an Android Virtual Device (AVD) to run it on (in the emulator)." ... Can you run "android list targets" from the command line and post the results? -- Kostya prachi <prachi.tya...@wipro.com> () Wed, 05 May 2010 14:28:44 +0400:
Hi harjeet While creating a new project u must specify the target SDK under build target list.It has a list of checkboxes specifying the the various paltforms.choose any one of them
Hello, While trying to create a new Android Project., Get a error - An SDK Target must be specified. The documentation states that - "Under Target, select an Android target to be used as the project's Build Target. The Build Target specifies which Android platform you'd like your application built against. " However in my case The Build Target section of the open dialog does not contain any text field or select dropdown, so I am not able to specify anything. Help in solving this is most appreciated. Thanks. --

3. How do I simulate a "Home", "Menu", Or "Back" key press

4. daya tahan batre Spica

5. Determine when application icon is clicked to launch the app

6. InputMethod feature problem

7. MicroSD 16GB Class 10