1

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?

4

2 回答 2

4
 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"/>
于 2012-09-12T04:37:23.917 回答
2
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.

于 2012-07-25T13:32:56.900 回答