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. what is the recording format of Intent .RECORD_SOUND_ACTION?

Hi,

can anyone tell me what is the default format of android recording.
i have recorded an audio clip but dont know how can i check its
extention?

i am using this activity

Intent intent = new Intent
(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, ACTIVITY_RECORD_SOUND);

i need mp3/wav format, is it the same or do i need to convert it? how?

please reply me

thanks.

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

2. SlideME Community Portal For Applications

The SlideME development team is pleased to announce the launch of a new
content portal for the discovery and delivery of Android applications:
http://slideme.org . This is a community portal with a focus on small
developers. You can upload Android applications, have it rated and commented
on, as well as find resources for promoting your skills and applications. We
also thought it was important to demonstrate the technology of discovering
and getting the content to a device, so we are also simultaneously releasing
the SlideME Community Edition Application Manager:
http://code.google.com/p/slideme under Apache License 2.0. SAMce will allow
you to discover, download and install from any JVending portal. You can find
more details on how this is done on the project site.

If you download SAMce, then by default, the client is hooked into SlideME
server so you can get started testing it without much effort. You can also
sign up for an account and submit your own content, which then become
available for others to see and download.

There is a pretty heavy focus in our group on open-source, so we were
careful in not tightly coupling the SAM client into the SlideME portal.  You
can set up your own instance of JVending  http://code.google.com/p/jvending
for testing with SAM or even to start building your own community, although
we hope you will find ours useful.

If you are a Maven user, you can use http://code.google.com/p/masa to
directly deploy your Android applications to slideme.org (or your own
instance of JV) as part of your release process. We are trying to make the
process of getting the apps to users as painless as possible.

Shane

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

3. Possibility of porting Android to the CECT P168C

4. Events not catched on real device using Activity.dispatch<EventType>

5. Default focus on RelativeLayout

6. About GLSurfaceView work mechanism

7. Can I use UNIQUE in the query() parameter?