Android open phone call application

15,202

Solution 1

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.

Solution 2

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.

Share:
15,202
AndroidDev
Author by

AndroidDev

Updated on June 08, 2022

Comments

  • AndroidDev
    AndroidDev almost 2 years

    I just want to open phone call application of android device. I dont want to provide that application a phone number. Just want to open it.
    I am using phone application's package name to open it. Because I am able to open any application I want through that package name with the code below.

    Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.contacts"); startActivity(launchIntent);

    I am not able to open Phone and Contacts application with the above code. What can be the problem?

  • AndroidDev
    AndroidDev almost 12 years
    I dont want to pick a call. I just want to open native phone call.
  • Juan Cortés
    Juan Cortés almost 12 years
    Have you even tried them? Because if you did, you'd have seen that they work.
  • AndroidDev
    AndroidDev almost 12 years
    ACTION_DIAL does work but I wanted to open that using package name. If I use one of your methods I need to hard code it to open Phone and contacts app which is bad. I can open any application I want with package name except these two apps. Try my code...
  • Fildor
    Fildor almost 12 years
    So, what you want is to open any application by package name, only these two do not work? Is that right? Then what's the errormessage?