Launch skype from an android app.

Antonio Auricchio 1 Reputation point
2022-07-19T06:43:39.577+00:00

Hello, I am in the process of developing with android studio on LINUX (kubuntu), in java code .
I would like to launch skype from an application.
I use
Uri skypeUri = Uri.parse(mySkypeUri);
Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
myIntent.setComponent(new ComponentName("com.skype4life", "com.skype.raider.Main"));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myContext.startActivity(myIntent);

When i run the application on my tablet device (not virtual) samsung galaxy tab s2 android version 7.0,
i get the "unfortunately the application has stopped to working".

when i replace com.skype.raider with com.skype4life, play store is launched and loading icon keeps spinning (no response).

Could some one help me?
Thank.

--- my entire java code ------------------------------------
package com.limbani.skypeintenthandler;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity
{
// Make sure you are sign in skype application if you not then you need to sign in
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    // Open skype button click event code here  
    ((Button) findViewById(R.id.openskype)).setOnClickListener(new OnClickListener()  
    {  
        @Override  
        public void onClick(View v)  
        {  
            String mySkypeUri = "skype:";  
            SkypeUri(MainActivity.this, mySkypeUri);  
        }  
    });  

    // skype message button click event code here  
    ((Button) findViewById(R.id.skypemsg)).setOnClickListener(new OnClickListener()  
    {  
        @Override  
        public void onClick(View v)  
        {  
            String skypeName = ((EditText) findViewById(R.id.edt_skypeusername)).getText().toString().trim();  
            if(skypeName.length()<=0)  
            {  
                Toast.makeText(getApplicationContext(), "Please enter skype username to message", Toast.LENGTH_SHORT).show();  
            }  
            else  
            {  
                String mySkypeUri = "skype:"+skypeName+"?chat";  
                SkypeUri(MainActivity.this, mySkypeUri);  
            }  
        }  
    });  

    // Skype Audio call button click event code here  
    ((Button) findViewById(R.id.skypecall)).setOnClickListener(new OnClickListener()  
    {  
        @Override  
        public void onClick(View v)  
        {  
            String skypeName = ((EditText) findViewById(R.id.edt_skypeusername)).getText().toString().trim();  
            if(skypeName.length()<=0)  
            {  
                Toast.makeText(getApplicationContext(), "Please enter skype username to call", Toast.LENGTH_SHORT).show();  
            }  
            else {  
                String mySkypeUri = "skype:"+skypeName+"?call";  
                SkypeUri(MainActivity.this, mySkypeUri);  
            }  
        }  
    });  

    // Skype Video call button click event code here  
    ((Button) findViewById(R.id.skypevideocall)).setOnClickListener(new OnClickListener()  
    {  
        @Override  
        public void onClick(View v)  
        {  
            String skypeName = ((EditText) findViewById(R.id.edt_skypeusername)).getText().toString().trim();  
            if(skypeName.length()<=0)  
            {  
                Toast.makeText(getApplicationContext(), "Please enter skype username to video call", Toast.LENGTH_SHORT).show();  
            }  
            else  
            {  
                String mySkypeUri = "skype:"+skypeName+"?call&video=true";  
                SkypeUri(MainActivity.this, mySkypeUri);  
            }  
        }  
    });  
}  

public void SkypeUri(Context myContext, String mySkypeUri) {  

    // Make sure the Skype for Android client is installed.  
    if (!isSkypeClientInstalled(myContext)) {  
        goToMarket(myContext);  
        return;  
    }  
    Uri skypeUri = Uri.parse(mySkypeUri);  
    Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);  
    myIntent.setComponent(new ComponentName("com.skype4life", "com.skype4life.Main"));  
    myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
    myContext.startActivity(myIntent);  

    return;  
}  

/**  
 * 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.skype4life", PackageManager.GET_ACTIVITIES);  
    }  
    catch (PackageManager.NameNotFoundException e) {  
        return (false);  
    }  
    return (true);  
}  

/**  
 * Install the Skype client through the market: URI scheme.  
 */  

public void goToMarket(Context myContext) {  
    Uri marketUri = Uri.parse("market://details?id=com.skype4life");  
    Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);  
    myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
    myContext.startActivity(myIntent);  
    return;  
}  

}

------------

com.skype.raider

Uri skypeUri = Uri.parse(mySkypeUri);
Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
myIntent.setComponent(new ComponentName("com.skype4life", "com.skype4life.Main"));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myContext.startActivity(myIntent);

Community Center Not monitored
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.