guys. I am trying to build a voip app for android. I want to make use of the built-in android phone dialer. Can you guys give me some reference to it. I have been googling with no luck. Thanks
2 Answers
What you need to do is setup an Intent
filter on the Activity
you want to make the call. You do this inside your AndroidManifest.xml file. Modify your activity definition to include this intent filter:
<intent-filter>
<action android:name="android.intent.action.CALL" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
Note: there are some alternative ways to call people (which can be seeing in the AndroidManifest.xml of the source I linked bellow, however this is the main one
Adding this will give the user the option to use your app when making a call, and this can be set as the default app if the user wishes.
You can then get the phone number by adding something like this code to your onCreate()
method of your activity:
final Intent i = getIntent();
final Uri phoneUri = i.getData();
phoneUri now contains tel:00000000000 and you can easily get the number out of the Uri object
If you have problems in to future take a look at the android source. I got these bits of code from the phone app source if you want to take a look.
-
hi above worked for me. THANKS! But I also want to put skype in that list when dialing a number, is there any way? – ruben Jun 14 '11 at 19:09
-
yes it surely does. Mistakenly I installed skype lite which doesn't :| – ruben Jun 28 '11 at 20:21
This should open the dialer with new special permissions:
Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:0000000000"));
startActivity(i);
That should open the dialer with the required telephone number already inserted.
-
what i am looking for is that the user is able to push the number on the dialer. After the user press call, it is using my voip app instead of the GSM phone. like how google voice does it. – CChi Aug 17 '10 at 08:41
-
1