1

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • You will have to make a query using ContentResolver to get the phone number by the name. Then you can use your approach! – Carnal Dec 15 '14 at 13:09
  • Check this out, but instead you add your contact name as a param to get the info about that person: http://stackoverflow.com/questions/20044399/how-to-get-contact-number-from-contactlist-in-android – Carnal Dec 15 '14 at 13:11
  • Or this, I think is what you are looking for: http://stackoverflow.com/questions/6330151/how-to-get-a-contacts-number-from-contact-name-in-android – Carnal Dec 15 '14 at 13:13
  • Thanks, let´s see if I can do something with those answers! –  Dec 15 '14 at 13:18
  • @user2683292 Do check this, it's exactly the same ur [trying](http://stackoverflow.com/a/12388353/1761003) – Maveňツ Dec 15 '14 at 13:53

1 Answers1

1

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

enter image description here

Maveňツ
  • 1
  • 12
  • 50
  • 89
  • Will it call the number of the contact name? –  Dec 15 '14 at 13:04
  • @user2683292 it will call to the number which is in the `textView` – Maveňツ Dec 15 '14 at 13:08
  • Will try to implement in my code, thank you! But @maveň where's the input? –  Dec 15 '14 at 13:45
  • 1
    @user2683292 `new String[]{id}` here id is input – Maveňツ Dec 15 '14 at 13:49
  • So it is possible to replace it with for example textInput instead of id? –  Dec 15 '14 at 13:52
  • Yes both are `String` u can do that.シ – Maveňツ Dec 15 '14 at 13:55
  • No problem :p I will ask you more when it doesn't work, I also have my source here: https://github.com/gi097/PWS/blob/master/src/nl/giovanniterlingen/pws/Main.java it's better to split when mostLikelyThingHeard is "Call Giovanni" it will split on "Call " then get "Giovanni" and then call Giovanni. –  Dec 15 '14 at 14:00