Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmaitcally making a VOIP call with Zoiper on an android tablet

I'm writing a simple Android app that has a button that makes a SIP call to a pre specified number. I'm using an Android tablet, version 4.0.4. I have set the button handler to do as follows:

Button button = (Button) rootView.findViewById(R.id.btnOpenDoor);
        button.setOnClickListener(new OnClickListener() {
            @Override
              public void onClick(View arg0) {
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:123456789"));
                startActivity(callIntent);
              }
        });

I expected that to bring up a "Which application would you like to use to dial this number" pop up (I have both Zoiper and CSipSimple installed). But instead it just pops up a dialog asking me if I would like to add this number to my contacts. I feel like this is because I'm using a tablet and not a phone. I've tried changing the Uri to sip:123456789 and zoiper:123456789. I've also tried setting the intent's package like so:

callIntent.setPackage("com.zoiper.android.app");

All to no avail. My permissions are as follows:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Can anyone help?

EDIT: I should say, I'm not limited to using Zoiper. Any SIP app should do. But I've definitely seem the "please choose which app to complete this action with" dialog pop up on phones when trying to dial a phone number from outside the dialer, with zoiper, skype and the actual dialer as well as anything else that supports dialling.

like image 208
Aaltan Ahmad Avatar asked Feb 01 '26 17:02

Aaltan Ahmad


1 Answers

This works for me, inspired by @user2999943's answer:

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("tel://" + 123456789));
startActivity(intent);
like image 163
Cody Avatar answered Feb 03 '26 05:02

Cody