我正在使用数组适配器在listview中加载数据。在列表视图中,我有电话号码,如果用户单击该号码,则呼叫功能会暂停。
  
  我的数组适配器类如下


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);
}



  并获取视图方法,依此类推...
  
  单击按钮以调用调用函数的代码


@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();
              }
        }



  我面临未发现异常的活动。如何解决呢?

最佳答案

Intent.ACTION_CALL的正确用法是

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);




因此,您正在设置的意图数据中缺少tel:。为了使您的代码工作,
更改

phoneIntent.setData(Uri.parse(holder.delivery_phone_number.getText().toString()));




phoneIntent.setData(Uri.parse("tel:" + holder.delivery_phone_number.getText().toString()));

08-18 07:05