Android 在片段中使用listview并呼叫拨号程序
我想通过Android 在片段中使用listview并呼叫拨号程序,android,Android,我想通过ImageView呼叫电话拨号器,我正在片段布局中使用Listview,我该怎么办 public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_appointments, container
ImageView
呼叫电话拨号器,我正在片段布局中使用Listview
,我该怎么办
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_appointments, container, false);
ListView listview = (ListView) v.findViewById(R.id.listview);
CustomAdapter customAdapter = new CustomAdapter();
listview.setAdapter(customAdapter);
imgv = (ImageView) v.findViewById(R.id.imphone);
imgv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
makeCall();
}
});
return v;
}
public void makeCall() {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel" +"99986326"));
startActivity(intent);
}
你必须这样改变它
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", "+99986326", null));
startActivity(intent);
这将不会直接拨打电话,而是打开填充您提供的号码的拨号程序。如果您必须直接从应用程序拨打电话,则操作\呼叫权限必须包含在清单中,并且在执行上述startactivity代码之前,有必要检查权限。您已经拨打电话,请告诉我们问题。当我单击手机图标时,请检查下面的答案应用程序崩溃。。。。。