我该如何为Skype播放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); }); 

首先你检查skype是否已经安装或者没有使用此代码。如果没有msg something.else去谷歌播放下载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); } 

嗨蒂娜请检查下面的代码,它的工作正常。

如果没有在设备上安装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; }