Reputation: 928
Making a Call through android device via phone and the code does not seems to work
I am call this function
private void call() {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("912345678"));
startActivity(callIntent);
} catch (ActivityNotFoundException activityException) {
Log.e("dialing-example", "Call failed", activityException);
}
}
also I have given the permission
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
What am I doing wrong any one can guide me?
Upvotes: 1
Views: 404
Reputation:
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number));
startActivity(intent);
make permission in manifest file:
<uses-permission android:name="android.permission.CALL_PHONE"/>
Upvotes: 4
Reputation: 46728
callIntent.setData(Uri.parse("tel:91234566"));
If you do not specify the scheme of the URI (tel:
in this case), it won't be recognized as a phone number and hence, the desired action will not occur.
Upvotes: 2