0

I have a long list of number and i want to open dialer with same number which is clicked if i use

Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:123"));
startActivity(intent);

then I have to write code for every number I want to know how to use single code for every number please help me

methode
  • 5,060
  • 2
  • 28
  • 42
axboy
  • 1
  • 3
  • Please edit your question and add a code snippet you tried to use. It would help people answering your question greatly! Read more about [how to ask a great question](http://stackoverflow.com/help/how-to-ask). – methode Jul 07 '15 at 05:00

1 Answers1

0

ArrayList Phone_Numbers=new ArrayList();

First of all put all the number in the arraylist then create a listview and set that arraylist to it.

Populating a ListView using an ArrayList?

then seta setonitemclicklisterner on that list for that have a look at below link

http://androidexample.com/Create_A_Simple_Listview_-_Android_Example/index.php?view=article_discription&aid=65&aaid=90

Explanation for below code when you will click on the item on list below listener will be invoked and on that by using int position you can get the specific Phone Number.

 listView.setOnItemClickListener(new OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> parent, View view,
                 int position, long id) {

                // in itemValue you will have the phone number.
                String  itemValue    = Phone_Numbers.get(position);

               //now call the function to open the dialer with that specified number

             open_Phone_Dialer(itemValue);
              }

         }); 

 public void open_Phone_Dialer(String phone_Number) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:" + phone_Number));
    startActivity(intent);
}
Community
  • 1
  • 1
Moubeen Farooq Khan
  • 2,815
  • 1
  • 8
  • 26