gpt4 book ai didi

java - 无法在 android studio os x 上导入 google 云消息服务

转载 作者:行者123 更新时间:2023-12-01 11:39:22 24 4
gpt4 key购买 nike

我被困在 android studio 里了;我是 iOS 开发者,刚刚接触 Android。我正在尝试制作一个带有推送通知的简单 webView 应用程序。

正如您在我的 mainActivity.java 中看到的,导入语句为灰色,checkPlayServices() 为红色。我已经完成了[官方教程]中的所有步骤,并且已经安装了您可以从 SDK 管理器安装的所有内容 (35GB)。我还检查了 SDK 目录是否正确。以下是 mainActivity、 list 文件、build.grapple 和 Activity_main.xml 的屏幕截图。

1 enter image description here

enter image description here

enter image description here

enter image description here

最佳答案

checkPlayServices() 呈红色,因为您没有这样的方法。在您的类中包含此方法:

private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}

检查Android GCM了解更多信息

关于java - 无法在 android studio os x 上导入 google 云消息服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29670180/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com