Retrieve HOME Contact Number from address book

by mike » Wed, 21 Apr 2010 17:10:29 GMT


Sponsored Links
 i guys,

currently i have a application which will retrieve all the contact
details and will display all the available Contact Names in a
SimpleCursorAdapter.

so once user select a particular name number will be displayed. which
works fine.

but now i want to display HOME and WORK numbers if available. how can
i achieve this?

below is my class

public class ConL extends ListActivity {
private SimpleCursorAdapter myAdapter;
TextView stat;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
stat = (TextView) findViewById(R.id.label);
viewContacts();
}

public void viewContacts() {
Cursor cursor = getContentResolver().query(People.CONTENT_URI,
null,
null, null, People.NAME + " ASC");
startManagingCursor(cursor);
int x = cursor.getCount();
if (cursor == null || x == 0) {
alert("Address Book", "Empty Address Book");
}
String[] columns = new String[] { People.NAME };
int[] names = new int[] { R.id.label };
myAdapter = new SimpleCursorAdapter(this, R.layout.test, cursor,
columns, names);
setListAdapter(myAdapter);
}

public void alert(String header, String body) {
new AlertDialog.Builder(this).setTitle(header).setMessage(body)
.setCancelable(true).setNeutralButton("Close",
new
DialogInterface.OnClickListener() {

@Override
public void
onClick(DialogInterface dialog,
int
which) {
// TODO
Auto-generated method stub
}
}).show();
}

protected String[] isAssigned(String[] str) {
String[] assign = null;
for (int i = 0; i < str.length; i++) {
Cursor cur = managedQuery(People.CONTENT_URI, null,
People.NAME
+ "='" + str[i] + "'", null, null);
if (cur != null) {
if (cur.moveToFirst()) {
String title;
// String phoneNumber;
int nameColumn =
cur.getColumnIndex(People.NUMBER);
// int phoneColumn =
cur.getColumnIndex(People.NUMBER);
// String imagePath;
do {
// Get the field values

} while (cur.moveToNext());
}
}
}
return assign;
}

@Overri



Retrieve HOME Contact Number from address book

by mike » Wed, 21 Apr 2010 17:16:26 GMT


 i guys,

currently i have a application which will retrieve all the contact
details and will display all the available Contact Names in a
SimpleCursorAdapter.

so once user select a particular name number will be displayed. which
works fine.

but now i want to display HOME and WORK numbers if available. how can
i achieve this?

below is my class

public class ConL extends ListActivity {
private SimpleCursorAdapter myAdapter;
TextView stat;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
stat = (TextView) findViewById(R.id.label);
viewContacts();
}

public void viewContacts() {
Cursor cursor = getContentResolver().query(People.CONTENT_URI,
null,
null, null, People.NAME + " ASC");
startManagingCursor(cursor);
int x = cursor.getCount();
if (cursor == null || x == 0) {
alert("Address Book", "Empty Address Book");
}
String[] columns = new String[] { People.NAME };
int[] names = new int[] { R.id.label };
myAdapter = new SimpleCursorAdapter(this, R.layout.test, cursor,
columns, names);
setListAdapter(myAdapter);
}

public void alert(String header, String body) {
new AlertDialog.Builder(this).setTitle(header).setMessage(body)
.setCancelable(true).setNeutralButton("Close",
new
DialogInterface.OnClickListener() {

@Override
public void
onClick(DialogInterface dialog,
int
which) {
// TODO
Auto-generated method stub
}
}).show();
}

protected String[] isAssigned(String[] str) {
String[] assign = null;
for (int i = 0; i < str.length; i++) {
Cursor cur = managedQuery(People.CONTENT_URI, null,
People.NAME
+ "='" + str[i] + "'", null, null);
if (cur != null) {
if (cur.moveToFirst()) {
String title;
// String phoneNumber;
int nameColumn =
cur.getColumnIndex(People.NUMBER);
// int phoneColumn =
cur.getColumnIndex(People.NUMBER);
// String imagePath;
do {
// Get the field values

} while (cur.moveToNext());
}
}
}
return assign;
}

@Overri


Sponsored Links


Other Threads

1. Update : Droid X harga spesial (Booked)

Mau update status WTS semalam,

Droid X sudah ada yg booked yah, considered sold.

Lelang Evo masih dibuka s.d pukul 23 nanti, setelah ditutup nanti akan
diumumkan peserta beserta harga penawarannya, supaya fair.
Sudah ada 2 penawar. Ayo bid, spy yakin menang.

-- 
===============
"

2. Android SDK for Android

Is it possible to run a android sdk on android itself? Ie. develop and
maintain software only using a android device?

-- 

3. Accessing Video Thumbnail

4. spica froyo kitchen... alpha...

5. Streaming di android

6. Facebook Publish Error In Anroid Application

7. when i connect facebook through android after sign in ....