how to make Intent.ACTION_CALL in Array adapter android facing activity not found exception -
i using array adapter load data in listview. in list view have phone number , if user clicks number , calling function should hapen.
my array adapter class follows
public class pendingdeliveryadapter extends arrayadapter<pendingdeliverypojoclass>{ private layoutinflater inflater; private context context; public pendingdeliveryadapter(context context,list<pendingdeliverypojoclass> data) { super(context,r.layout.listview_pending_delivery,data); this.context = context; inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); }
and view method on...
code call calling functions in button click
@override public void onclick(view view) { intent phoneintent = new intent(intent.action_call); phoneintent.setdata(uri.parse(holder.delivery_phone_number.gettext().tostring())); try { context.startactivity(phoneintent); } catch (android.content.activitynotfoundexception ex) { toast.maketext(getcontext(), "call faild, please try again later.", toast.length_short).show(); } }
i facing activity not found exception . how solve this?
the correct use of intent.action_call
intent intent = new intent(intent.action_call); intent.setdata(uri.parse("tel:" + number)); startactivity(intent);
so tel:
missing data of intent, setting. make working code, change
phoneintent.setdata(uri.parse(holder.delivery_phone_number.gettext().tostring()));
with
phoneintent.setdata(uri.parse("tel:" + holder.delivery_phone_number.gettext().tostring()));
Comments
Post a Comment