android - On button click number copy to dial screen, in list view -
android - On button click number copy to dial screen, in list view -
this program.
in android project there 1 xml file in button is. upon on-clicking of button, dial screen displayed, want.
here code tried:
arraylist<hashmap<string, string>> list = new arraylist<hashmap<string, string>>(); @override public void oncreate(bundle abc) { //super.oncreate(savedinstancestate); super.oncreate(abc); hashmap<string, string> item = new hashmap<string, string>(); hashmap<string, string> item2 = new hashmap<string, string>(); hashmap<string, string> item3 = new hashmap<string, string>(); item.put("name", "taxi sure"); item.put("number", "020 6060 1010"); item.put("address", "for pune city"); item2.put("name", "ola cabs"); item2.put("number", "020 3355 3355"); item2.put("address", "for pune city"); item3.put("name", "savaari car"); item3.put("number", "1800 108 1000"); item3.put("address", "for pune city"); list.add(item); list.add(item2); list.add(item3); string[] columns = new string[]{"name", "number", "address"}; int[] renderto = new int[]{r.id.name, r.id.number, r.id.address}; listadapter listadapter = new simpleadapter(this, list, r.layout.taxi_row, columns, renderto); setlistadapter(listadapter); public void onclick(view view) { int id = view.getid(); int pos = (integer) view.gettag(); string number = list.get(pos).get("number"); if (id == r.id.imagebutton_call) { intent callintent = new intent(); callintent.setaction(intent.action_dial); callintent.setdata(uri.parse("tel:" + number)); startactivity(callintent); } }
try this:
try { intent callintent = new intent(intent.action_dial); callintent.setdata(uri.parse("tel:"+number)); context.startactivity(callintent); } grab (activitynotfoundexception activityexception) { toast.maketext(context, context.getstring("call has failed"), toast.length_long).show(); } }
and create sure have permission in androidmanifest.xml file:
<uses-permission android:name="android.permission.call_phone" />
android
Comments
Post a Comment