How to start a Skype call from an Android app?

前端 未结 4 856
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 06:33

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

相关标签:
4条回答
  • 2020-12-03 06:36

    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.

    0 讨论(0)
  • 2020-12-03 06:45

    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;
    }
    
    0 讨论(0)
  • 2020-12-03 06:56

    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);
            }
    
        }
    
    0 讨论(0)
  • 2020-12-03 06:59

    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.

    0 讨论(0)
提交回复
热议问题