Reputation: 5961
I get the number from user by editText and set as TextView is successful. How i implement the call intent:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.template);
final TextView crdMobile = (TextView) findViewById(R.id.crdMobile);
crdMobile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+"+crdMobile.getText().toString().trim()));
//callIntent.setData(Uri.parse(crdMobile.getText().toString().trim()));
startActivity(callIntent );
}
});
When I click on crdMobile, normal call interface appears on device. But there is no call being done. After few seconds of holding, call ends with no dialing. How can I improve or correct this?
Upvotes: 0
Views: 87
Reputation: 75645
To use ACTION_CALL
you need to hold related permission:
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
I suggest to switch to ACTION_DIAL
instead anyway, as it does not require any permission and will not exclude your app on devices that feature no telephony like tablets
Upvotes: 3