As you guys may suggest, I'm creating a SIRI with voice commands. Now I did like to add a call function. For example I have this code:
Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:" + findViewByid(R.id.textView).getText());
startActivity(call);
So the user has to type in a phone number. I did like to input a contact name instead of a number, and let the app automaticly scan the contacs book and dial that number instead. I searched a lot but I couldn't find what I was looking for.
So what I need to do is Resolve Content, I have no idea where to start.
Why don't you try this way:
For getting number from contact list
Cursor cursor = mContentResolver.query(CommonDataKinds.Phone.CONTENT_URI, null, CommonDataKinds.Phone.CONTACT_ID +" = ?", new String[]{id}, null);
while (cursor.moveToNext())
{
phone_number.add(cursor.getString(cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER)));
}
for calling
Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:" + phone_number.get(0)));
startActivity(call);
OUTPUT
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.