画像をクリックするだけでアプリケーションから電話をかけようとしていますが、これは次のように実行されますが、例外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();
}
}