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. Help with Services

Hi all,
              i'm starting an activity that inturn calls a service.... i
wanna get notified when the service competes...
can anyone temme how i can do this???

-- 
Regards,
Sujay
Bette Davis <http://www.brainyquote.com/quotes/authors/b/bette_davis.html>
- "Brought up to respect the conventions, love had to end in marriage.
I'm
afraid it did."

--~--~---------~--~----~------------~-------~--~----~

2. Screen Brightness

Hi,
I read here in several  posts thats possible with
   WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.screenBrightness = 100 / 100.0f;
        getWindow().setAttributes(lp);

to change the screen brightness.
ok, but it looks only for the actual activity. (there it works)

When I close my activity, the standart system brightness is still the
same

But how to change the overall brightness, like several tools for 1.5
do?

thanks
chris

--~--~---------~--~----~------------~-------~--~----~

3. emulator rotation on 1.5 with no keyboard on the device

4. xmlbeans support in 1.5

5. Toast without light up

6. SDCard becoming un-writeable

7. How to put an AppWidget on lock screen?