此代码用于在 Skype 上向某人发送消息,但我不知道如何设置https://play.google.com/store/apps/details?id=com.skype.raider https://play.google.com/store/apps/details?id=com.skype.raider以防我没有 Skype。
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 某些内容。否则请前往 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);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)