Launch Skype from an App Programmatically & Pass Number - Android

Solution 1:

This code works for me to start a call between two Skype users:

Intent sky = new Intent("android.intent.action.VIEW");
sky.setData(Uri.parse("skype:" + user_name));
startActivity(sky);

To find this (and others), use apktool to open up the Skype APK. Look at the AndroidManifest.xml and you'll see all the intent filters they know about. If you want to trigger one of those intent filters, you need to make an intent that will match one. Here's the intent filter that the code above is matching:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="skype" />
        </intent-filter>

You get the category "android.intent.category.DEFAULT" for free from {{new Intent()}}, so all that remains is to set the action and the URI.

The intent filter for tel: URIs looks like this:

        <intent-filter android:icon="@drawable/skype_blue" android:priority="0">
            <action android:name="android.intent.action.CALL_PRIVILEGED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="tel" />
        </intent-filter>

So you set to the action and give the Intent a tel: URI and "the right thing happens". What happens is that Android finds the correct provider for the tel: URI. It might get the user's input to choose between the Phone App and Skype. The priority for Skype to handle tel: URIs zero, which is lowest. So if the Phone App is installed, it will probably get the Intent.

Solution 2:

In case you want to trigger a video call you will have to add "?call&video=true" to your Skype URI.

Intent skypeVideo = new Intent("android.intent.action.VIEW");
skypeVideo.setData(Uri.parse("skype:" + "<username>" + "?call&video=true"));
startActivity(skypeVideo);

More information about Skype URIs are documented at: http://developer.skype.com/skype-uris-program/skype-uri-ref

EDIT :

Direct Skype call without any intent chooser :

If you want direct skype call without any intent chooser, add these lines in your manifest file...

               <intent-filter
                    android:icon="@drawable/skype"
                    android:priority="0" >
                    <action android:name="android.intent.action.CALL_PRIVILEGED" />

                    <category android:name="android.intent.category.DEFAULT" />

                    <data android:scheme="tel" />
                </intent-filter>
                <intent-filter>
                    <intent-filter
                        android:icon="@drawable/skype"
                        android:priority="0" >
                        <action android:name="android.intent.action.VIEW" />
                        <action android:name="android.intent.action.CALL" />

                        <category android:name="android.intent.category.BROWSABLE" />
                        <category android:name="android.intent.category.DEFAULT" />

                        <data android:scheme="skype" />
                    </intent-filter>


                </intent-filter>

Solution 3:

Use this code for Skype version 2:

Intent skype_intent = new Intent("android.intent.action.VIEW");
skype_intent.setClassName("com.skype.raider", "com.skype.raider.Main");
skype_intent.setData(Uri.parse("skype:skypeusername"));
startActivity(skype_intent);

Solution 4:

With this code you will get the intent of the Skype activity not the caller activity. So you have to find the intent for the activity which has the intent filter for action CALL. But more clearly Skype uses the action android.intent.action.CALL_PRIVILEGED, so find by this filter. Just for information that caller activity is cmp=com.skype.raider.contactsync.ContactSkypeOutCallStartActivity.