作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
此代码是通过 Skype 向某人发送消息,但我不知道如何设置 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);
}
关于java - 我如何在 Skype 上玩 google?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27053628/
我是一名优秀的程序员,十分优秀!