How can I play.google for Skype?

前端 未结 2 1527
慢半拍i
慢半拍i 2021-01-27 06:22

This code is to msg somethone om Skype but I don\'t know how to set https://play.google.com/store/apps/details?id=com.skype.raider in case I didn\'t have Skype.

         


        
相关标签:
2条回答
  • 2021-01-27 06:33

    Hi Tina Please check below code its working fine.

    If not install skype on device open google play otherwise open 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;
        }
    
    0 讨论(0)
  • 2021-01-27 06:48

    First you check skype is already installed or not using this code .if insalled msg something.else go to google play to download 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);
         }
    
    0 讨论(0)
提交回复
热议问题