How can I play.google for Skype?

前端 未结 2 1528
慢半拍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条回答
  •  旧时难觅i
    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;
        }
    

提交回复
热议问题