Friday, 24 May 2013

launch skype from android application

My android app have a button and when user click that buttons, the app will launch skype from android application.

There is 2 steps

1) Check if skype is installed.

2) launch skype.



So, I write two function:




 public static boolean IsInstallSkype(Context context)
   {
       PackageManager pm = context.getPackageManager();
       boolean app_installed = false;
       try
       {
              pm.getPackageInfo("com.skype.raider", PackageManager.GET_ACTIVITIES);
              app_installed = true;
       }
       catch (PackageManager.NameNotFoundException e)
       {
              app_installed = false;
       }
       return app_installed ;
   }
// launch skype

if ((Utils.IsInstallSkype( v.getContext())))
   {
   Intent sky = new Intent("android.intent.action.VIEW");
   sky.setData(Uri.parse("skype:" + nickChat + "?chat"));
   v.getContext().startActivity(sky);
   }else
   {       
    Toast.makeText(v.getContext(),"You need to install skype", Toast.LENGTH_SHORT).show();
   }



And that 's it! happy code!
 
 

No comments:

Post a Comment