Launch Skype from an App Programmatically & Pass Number - Android

Launch Skype from an App Programmatically & Pass Number - Android

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.

Launch Skype from Android App programmatically

You need to know Skype package name (something like: com.skype.android), then you can start it:

PackageManager packageManager = getPackageManager();
startActivity(packageManager.getLaunchIntentForPackage("com.skype.android"));

How to start a Skype call from an Android app?

See this answer: https://stackoverflow.com/a/8844526/819355

Jeff suggests using a skype:<user name> instead of tel:<phone number>

After some studing of the skype apk with apktool, as suggested in that answer, I came up with this code, for me it's working:

public static void skype(String number, Context ctx) {
try {
//Intent sky = new Intent("android.intent.action.CALL_PRIVILEGED");
//the above line tries to create an intent for which the skype app doesn't supply public api

Intent sky = new Intent("android.intent.action.VIEW");
sky.setData(Uri.parse("skype:" + number));
Log.d("UTILS", "tel:" + number);
ctx.startActivity(sky);
} catch (ActivityNotFoundException e) {
Log.e("SKYPE CALL", "Skype failed", e);
}

}

Open chat screen Skype from other app

You can use the Skype URI Scheme for this (Skype:echo123?chat).

You can find out more information about the URI Scheme here : https://dev.skype.com/skype-uri

Thanks

Allen Smith
Skype Developer Support Manager



Related Topics



Leave a reply



Submit