I am implementing a call intent in my android application. However, every time I click on the button, the application suffers force close. I have added android.permission.CALL_PHONE to my manifest. Also, the email button is working fine.
I am fetching the number from a mysql database using the following code:
phonenumber = json_data.getString("phone");
and this is the OnClickListener for the button
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String number = phonenumber;
Intent callintent = new Intent(android.content.Intent.ACTION_CALL);
callintent.putExtra(android.content.Intent.EXTRA_PHONE_NUMBER, number);
startActivity(callintent);
}
});
Is there a problem with using the string, since the JSON data is converted to a string?
Just try this,