我如何播放Skype的Skype?

时间:2014-11-21 03:28:54

标签: java android eclipse message skype

此代码用于向Skype发送消息,但我不知道在没有Skype的情况下如何设置https://play.google.com/store/apps/details?id=com.skype.raider

skypename.setOnClickListener(new OnClickListener() {
                  @Override
                   public void onClick(View v) {
                      Uri skypeUri = Uri.parse("skype:username?chat");
                      Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
                      myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
                      myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                      startActivity(myIntent); 
                      }
                  });

代码已添加............................................. .................................................. ....

skypename.setOnClickListener(new OnClickListener() {
   @Override
     public void onClick(View v) {
      if (!isSkypeClientInstalled(activity)) {
        Context activity;
        goToMarket(activity);
        return;
     } else{ 
       Uri skypeUri = Uri.parse("skype:username?chat");
       Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
       myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
       myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       startActivity(myIntent); 
       }

public void goToMarket(Context myContext) {
   Activity activity;
  try {
      activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + "com.skype.raider")));
                    } catch (android.content.ActivityNotFoundException anfe) {
                         activity. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + "com.skype.raider")));
                    }
                      return;
                     }
                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);
                     });

2 个答案:

答案 0 :(得分:1)

首先你检查skype是否已经安装或者没有使用此代码。如果安装了消息something.else去google play下载skype

skypename.setOnClickListener(new OnClickListener() {
           @Override
             public void onClick(View v) {
              if (!isSkypeClientInstalled(MainActivity.this)) {

                goToMarket(MainActivity.this);
                return;
             } else{ 
               Uri skypeUri = Uri.parse("skype:username?chat");
               Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
               myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
               myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
               startActivity(myIntent); 
               }
           }
                });

public void goToMarket(Context myContext) {

    try {
       activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + "com.skype.raider")));
    } catch (android.content.ActivityNotFoundException anfe) {
         activity. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + "com.skype.raider")));
    }

      return;
     }
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);
     }

答案 1 :(得分:0)

Hi Tina请检查以下代码是否正常工作。

如果没有在设备上安装Skype,请打开谷歌播放,否则打开Skype。

Button button = (Button) findViewById(R.id.button1);
        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                try {
                    if (appInstalledOrNot("com.skype.raider")) {
                        Intent sky = new Intent("android.intent.action.VIEW");
                        sky.setData(Uri.parse("skype:" + ""));
                        startActivity(sky);
                    } else {
                        Intent i = new Intent(
                                android.content.Intent.ACTION_VIEW);
                        i.setData(Uri
                                .parse("https://play.google.com/store/apps/details?id=com.skype.raider"));
                        startActivity(i);
                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });
    }

    private boolean appInstalledOrNot(String uri) {
        PackageManager pm = getPackageManager();
        boolean app_installed = false;
        try {
            pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
            app_installed = true;
        } catch (PackageManager.NameNotFoundException e) {
            app_installed = false;
        }
        return app_installed;
    }