5

I create a call directly using the default os dialer by:

Intent call = new Intent(Intent.ACTION_CALL);
call.setData(Uri.parse("tel:" + phoneNo));
startActivity(call);

Is it possible to launch Skype directly from my app?

I try to pass a number as follows:

PackageManager packageManager = getPackageManager();
Intent skype = packageManager.getLaunchIntentForPackage("com.skype.raider");
skype.setData(Uri.parse("tel:65465446"));
startActivity(skype);

Passing the number fails.

Cœur
  • 34,719
  • 24
  • 185
  • 251
ruben
  • 1,758
  • 5
  • 25
  • 47
  • ..thanks for your question which help me ..i have one doubt that how could we get the package name for the particular app –  Apr 11 '13 at 10:57
  • maybe looking at logcat can help when you are running that app in the device and device is connected to eclipse – ruben Apr 11 '13 at 12:15
  • Possible duplicate of [Launch Skype from an App Programmatically & Pass Number - Android](http://stackoverflow.com/questions/6414494/launch-skype-from-an-app-programmatically-pass-number-android) – Yara_M Oct 27 '16 at 14:08

2 Answers2

3

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"));
jamapag
  • 9,260
  • 4
  • 32
  • 28
1

In your case there may be bellow case happen:

  1. Skype not installed
  2. Skype is disabled
  3. Skype is installed

For case 1 and 2 you won't able to call skype. For case 3 you can call via skype. Please check the bellow cases for start skype:

String appName = "Skype";
String packageName = "com.skype.raider";
openApp(context, appName, packageName);

public static void openApp(Context context, String appName, String packageName) {
    if (isAppInstalled(context, packageName))
        if (isAppEnabled(context, packageName))
            context.startActivity(context.getPackageManager().getLaunchIntentForPackage(packageName));
        else Toast.makeText(context, appName + " app is not enabled.", Toast.LENGTH_SHORT).show();
    else Toast.makeText(context, appName + " app is not installed.", Toast.LENGTH_SHORT).show();
}

Check is app installed or not :

private static boolean isAppInstalled(Context context, String packageName) {
        PackageManager pm = context.getPackageManager();
        try {
            pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
            return true;
        } catch (PackageManager.NameNotFoundException ignored) {
        }
        return false;
    }

Check is app enabled or not :

private static boolean isAppEnabled(Context context, String packageName) {
        boolean appStatus = false;
        try {
            ApplicationInfo ai = context.getPackageManager().getApplicationInfo(packageName, 0);
            if (ai != null) {
                appStatus = ai.enabled;
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return appStatus;
    }
Md. Sajedul Karim
  • 7,031
  • 3
  • 56
  • 81