我正在尝试通过单击图像从我的应用程序进行调用,它是通过这样完成的,但它给了我异常 ActivityNotFoundException 我应该如何处理这个..?
Image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if("N/A".equals(Number)){
MsgBox(ctx,"Could not call because there is no number ");
}
else{
fnCallMobile("+91"+Number);
}
}
});
我的 fnCallMobile 函数是:
public void fnCallMobile(String PhoneNo){
ConfirmMsgBox(this,"Are you sure you want to call number "+PhoneNo,PhoneNo);
}
public void ConfirmMsgBox(Context ctx,String msg,final String sPhoneNo){
final AlertDialog.Builder dialog=new AlertDialog.Builder(this);
dialog.setTitle("Emkay Eagle");
dialog.setMessage(msg);
dialog.setCancelable(false);
dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
fnCall(sPhoneNo);
}
});
dialog.setNegativeButton("No", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
return;
}
});
AlertDialog alert = dialog.create();
alert.setIcon(R.drawable.icon);
alert.show();
return;
}
最后是我的 fnCall 函数
public void fnCall(String PhoneNo){
try{
Intent callIntent=new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("Tel:"+PhoneNo));
startActivity(callIntent);
}
catch(ActivityNotFoundException ex){
sResponse=ex.toString();
}
}