简体   繁体   中英

dial a number automatically in android

I can't figure out how to make the app dial.

I have this code:

public void dial(String number)
{
    Intent intent = new Intent(Intent.ACTION_DIAL);//calling intent
    intent.setData(Uri.parse("tel:" + number));
    if (intent.resolveActivity(getPackageManager()) != null) 
    {
        startActivity(intent);
    }
}

but it only opens the dialer app. i need it to dial the given number..

any help would be appreciated!!

Change ACTION_DIAL to ACTION_CALL . This will require the CALL_PHONE permission.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM