7

I'm trying to start a Skype intent from my Android App, passing a phone number. So far, thanks to other people who ad similiar needs here on stackoverflow, I've managed to start skype, but still I can't pass the phone number. This is the code I'm using:

Intent sky = new Intent("android.intent.action.CALL_PRIVILEGED");
        sky.setClassName("com.skype.raider",
                "com.skype.raider.Main");
        sky.setData(Uri.parse("tel:" + number));
        Log.d("UTILS", "tel:" + number);
        ctx.startActivity(sky);

What's happening is that skype starts, but gives me a toast saying that the number is not valid, and suggests me to add the international prefix. The Log.d gives me tel:+39........ (the number works, I'm using it also for

public static void call(String number, Context ctx) {
    try {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + number));
        ctx.startActivity(callIntent);
    } catch (ActivityNotFoundException e) {
        Log.e("helloandroid dialing example", "Call failed", e);
    }

}

In fact, when I go to the Skype's view for calling, I see it's been composed +0 So what it seems to me is that I'm passing the phone number in the wrong way, or to the wrong Activity....any help would be very appreciated! In the meantime, I just want to say that StackOverflow simply rocks.

Daniele
  • 1,063
  • 1
  • 10
  • 22
  • This works perfectly (for me). I needed a way to start a Skype Call without any intervention by the user. – user462990 Apr 07 '13 at 12:37
  • how to programmatically enter the credentials for Skype login screen? It may be possible that user is not logged into the app – Parth Doshi Feb 29 '16 at 05:43

4 Answers4

17

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);
        }

    }
Community
  • 1
  • 1
marmor
  • 27,641
  • 11
  • 107
  • 150
  • If the answer was helpful please mark it as accepted so other people can use it, if you've solved the problem in a different way, you can answer your own question and accept it – marmor Jun 29 '12 at 08:56
  • This answer was helpful, but didn't contain the exact procedure, should I write the working code as answer to my question or edit the question? – Daniele Jul 23 '12 at 08:08
  • This works perfectly (for me). I needed a way to start a Skype Call without any intervention by the user. – user462990 Apr 07 '13 at 12:38
  • well i tried it but its only opening akype app and not calling the number.any idea? – TheGraduateGuy Jan 15 '14 at 12:27
  • How to make skype video call? – Sara Nov 17 '15 at 06:45
  • Is it possible to do the same, but for chat? Also, is it possible to put a phone number instead? – android developer Mar 15 '16 at 13:10
  • @androiddeveloper if it works in the Skype app, it *might* work as an intent. Try using https://play.google.com/store/apps/details?id=com.zmarties.detective to see Skype's manifest file, and check the public intents they support – marmor Mar 15 '16 at 13:17
  • @marmor I've found it eventually, but thanks for trying to help. Here's the result: http://stackoverflow.com/q/35972329/878126 . No idea why my question is so downvoted. I even answered myself with a lot of info. – android developer Mar 15 '16 at 13:35
7

Refer to Skype developer: Skype URI tutorial: Android apps Also remember to add "?call" in your url. E.g

intent.setData(Uri.parse("skype:" + phoneNumber + "?call"));

Without it, Skype may not dial the number.

Upendra Shah
  • 2,218
  • 17
  • 27
HiMobilet
  • 71
  • 2
  • 2
  • how to programmatically enter the credentials for Skype login screen? It may be possible that user is not logged into the app – Parth Doshi Feb 12 '16 at 02:30
  • I felt no difference without "?call" part. Also, the "skype:" stuff is only working on modern Skype for me. Old ones just pop up skype dial screen but didn't place call. Using usernames instead of phones made it work in all cases. The problem with numbers using "skype:" happend to me even when trying to run it from `am start skype:phonenumber`. – m3nda Nov 24 '17 at 02:15
4

You should not include a specific class when calling an external app. Let the user decide of the application he/she wants to use. That's the way android has been designed and it's a better solution than obliging people to use a soft (moreover quite a slow, closed and inconvenient app to my mind).

In other words, just use the Uri, that's the job of skype of declaring its ability to capture such intents.

Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • 1
    Hi, thanks for the answer. I know, and I've already tried to explain this to my client, of course, but, sadly, here I am, trying to do this thing... – Daniele Apr 13 '12 at 08:33
  • how to programmatically enter the credentials for Skype login screen? It may be possible that user is not logged into the app – Parth Doshi Feb 29 '16 at 05:43
0

Refer this skype doc link Skype URI tutorial: Android apps

First need to check skype is installed or not using

/**
 * Determine whether the Skype for Android client is installed on this device.
 */
public boolean isSkypeClientInstalled(Context myContext) {
  PackageManager myPackageMgr = myContext.getPackageManager();
  try {
    myPackageMgr.getPackageInfo("com.skype.raider", PackageManager.GET_ACTIVITIES);
  }
  catch (PackageManager.NameNotFoundException e) {
    return (false);
  }
  return (true);
}

initiate skype uri using

/**
 * Initiate the actions encoded in the specified URI.
 */
public void initiateSkypeUri(Context myContext, String mySkypeUri) {

  // Make sure the Skype for Android client is installed.
  if (!isSkypeClientInstalled(myContext)) {
    goToMarket(myContext);
    return;
  }

  // Create the Intent from our Skype URI.
  Uri skypeUri = Uri.parse(mySkypeUri);
  Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);

  // Restrict the Intent to being handled by the Skype for Android client only.
  myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
  myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

  // Initiate the Intent. It should never fail because you've already established the
  // presence of its handler (although there is an extremely minute window where that
  // handler can go away).
  myContext.startActivity(myIntent);

  return;
}

if Skype is not installed then redirect to market place using

/**
 * Install the Skype client through the market: URI scheme.
 */
public void goToMarket(Context myContext) {
  Uri marketUri = Uri.parse("market://details?id=com.skype.raider");
  Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
  myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  myContext.startActivity(myIntent);

  return;
}
Upendra Shah
  • 2,218
  • 17
  • 27