Launch Skype from Android App programmatically

后端 未结 2 2046
慢半拍i
慢半拍i 2020-12-20 21:53

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

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


        
相关标签:
2条回答
  • 2020-12-20 22:07

    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"));
    
    0 讨论(0)
  • 2020-12-20 22:11

    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;
        }
    
    0 讨论(0)
提交回复
热议问题