I am trying to make a call from my Application on a click of a image
and it is here by done like this But it is Giving me Exception ActivityNotFoundException
How Should i handle this .. ?
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);
}
}
});
And my fnCallMobile function is :
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;
}
And lastly my fnCall Function
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();
}
}
1 Answer