Android open phone call application

戏子无情 提交于 2019-12-04 14:56:25

Intents are intended (no pwn intended here (damn!)) to give you a more generic way of accessing actions such as opening a file. If you had to specify the package of whatever you wanted to do this would be very limited. However, here are some of the intents that may be what you're after.

//For the contacts (picking one)
 Intent i = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
//For the contacts (viewing them) 
 Intent i = new Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI);
//For the dial pad
 Intent i = new Intent(Intent.ACTION_DIAL, null);
//For viewing the call log
 Intent i = new Intent(Intent.ACTION_VIEW, CallLog.Calls.CONTENT_URI);

Make yourself a useful intents file somewhere to save you time in the future, you'll thank me later someday.

Of course to start those intents you'd do startActivity(i); for all excepting the first one, since you'd want the contact back and you'd need startActivityForResult(i); but that's another story.

public static final String ACTION_DIAL

Since: API Level 1 Activity Action: Dial a number as specified by the data. This shows a UI with the number being dialed, allowing the user to explicitly initiate the call. Input: If nothing, an empty dialer is started;

Source: http://developer.android.com/reference/android/content/Intent.html#ACTION_DIAL

http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL could be also what you are looking for.

If you want to start the phone call from an Activity, just use http://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent) from the Activity's Context.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!