- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
google play 服务适用于 Lollipop ,但当涉及到 kitkat 和更低版本时,即使设备上安装了 google-play-services,它也会给出 ConnectionResult 错误=1。
这是我的代码。
顶层 Build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.yembrace.android.app"
minSdkVersion 19
targetSdkVersion 21
maxSdkVersion 22
versionCode 4
versionName "1.0.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile "com.google.android.gms:play-services-gcm:8.3.0"
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.android.support:cardview-v7:23.1.0'
//beacons sdk
compile 'com.estimote:sdk:0.8.8@aar'
compile 'com.github.clans:fab:1.6.2'
//Cards
compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
}
public class LoginActivity extends Activity implements
View.OnClickListener,
ActivityCompat.OnRequestPermissionsResultCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
private static final String TAG = "TAG";
private static final int RC_SIGN_IN = 1;
private static final int RC_PERM_GET_ACCOUNTS = 2;
private static final String KEY_IS_RESOLVING = "is_resolving";
private static final String KEY_SHOULD_RESOLVE = "should_resolve";
private GoogleApiClient mGoogleApiClient;
private boolean mIsResolving = false;
private boolean mShouldResolve = false;
SharedPreferences sharedPreferences;
private ViewPager mViewPager;
PageIndicator mIndicator;
private String message;
private SignInButton google_signin;
private ProgressBar progressBar;
private ServiceUtils serviceUtils;
private ProfileData profileData;
private BroadcastReceiver mRegistrationBroadcastReceiver;
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
{
progressBar = (ProgressBar) findViewById(R.id.progress_bar);
progressBar.setIndeterminate(true);
progressBar.setVisibility(View.INVISIBLE);
}
profileData = new ProfileData();
serviceUtils = new ServiceUtils(this);
initGoogle();
sharedPreferences = getSharedPreferences("app_pref", MODE_PRIVATE);
if (savedInstanceState != null) {
mIsResolving = savedInstanceState.getBoolean(KEY_IS_RESOLVING);
mShouldResolve = savedInstanceState.getBoolean(KEY_SHOULD_RESOLVE);
}
}
private void initGoogle() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(new Scope(Scopes.PROFILE))
.addScope(new Scope(Scopes.EMAIL))
.build();
google_signin = (SignInButton) findViewById(R.id.sign_in_button);
google_signin.setSize(SignInButton.SIZE_WIDE);
google_signin.setColorScheme(SignInButton.COLOR_DARK);
for (int i = 0; i < google_signin.getChildCount(); i++) {
View v = google_signin.getChildAt(i);
if (v instanceof TextView) {
TextView tv = (TextView) v;
tv.setPadding(0, 0, 20, 0);
}
}
google_signin.setOnClickListener(this);
}
private void updateUI(boolean isSignedIn) {
if (isSignedIn) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
if (currentPerson != null) {
profileData.setEmail(Plus.AccountApi.getAccountName(mGoogleApiClient));
profileData.setPlatform("google");
if (currentPerson.hasName()) profileData.setFullName(currentPerson.getDisplayName());
if (currentPerson.hasImage()) profileData.setProfileImgUrl(currentPerson.getImage().getUrl());
if (currentPerson.hasId()) profileData.setPlatformProfileId(currentPerson.getId());
if (currentPerson.hasCover() && currentPerson.getCover().hasCoverPhoto()) profileData.setProfileCoverUrl(currentPerson.getCover().getCoverPhoto().getUrl());
if (currentPerson.hasBirthday()) profileData.setBirthday(currentPerson.getBirthday());
if (currentPerson.hasGender()) profileData.setGender(String.valueOf(currentPerson.getGender()));
if (currentPerson.hasRelationshipStatus()) profileData.setRelationshipStatus(String.valueOf(currentPerson.getRelationshipStatus()));
if (currentPerson.hasAgeRange()){ profileData.setMaxAge(String.valueOf(currentPerson.getAgeRange().getMax()));profileData.setMinAge(String.valueOf(currentPerson.getAgeRange().getMin()));}
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("platform", profileData.getPlatform());
editor.putString("userName", profileData.getFullName());
editor.putString("userEmail", profileData.getEmail());
editor.putString("profileImage", profileData.getProfileImgUrl());
editor.putString("profileCover",profileData.getProfileCoverUrl());
editor.commit();
registerUser();
} else {
Log.d(TAG, "Null Person, check the api-key");
handleError("Connection Error");
}
} else {
Log.d(TAG, "In UpdateUI: User not signedIn");
handleError("Connection Error");
}
}
private void showSignedInUI() {
updateUI(true);
}
@Override
protected void onStop() {
super.onStop();
mGoogleApiClient.disconnect();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_IS_RESOLVING, mIsResolving);
outState.putBoolean(KEY_SHOULD_RESOLVE, mShouldResolve);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
if (resultCode != RESULT_OK) {
mShouldResolve = false;
}
mIsResolving = false;
mGoogleApiClient.connect();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
if (requestCode == RC_PERM_GET_ACCOUNTS) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
showSignedInUI();
} else {
Log.d(TAG, "GET_ACCOUNTS Permission Denied.");
}
}
}
@Override
public void onConnected(Bundle bundle) {
Log.d(TAG, "onConnected:" + bundle);
mShouldResolve = false;
showSignedInUI();
}
@Override
public void onConnectionSuspended(int i) {
Log.w(TAG, "onConnectionSuspended:" + i);
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
Log.d(TAG, "onConnectionFailed:" + connectionResult.getErrorCode());
if (!mIsResolving && mShouldResolve) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, RC_SIGN_IN);
mIsResolving = true;
Log.d(TAG, "Could not resolve ConnectionResult.");
} catch (IntentSender.SendIntentException e) {
Log.d(TAG, "Could not resolve ConnectionResult.", e);
handleError("Connection Error");
mIsResolving = false;
mGoogleApiClient.connect();
}
} else {
showErrorDialog(connectionResult);
}
} else {
handleError("Connection Error");
}
}
private void showErrorDialog(ConnectionResult connectionResult) {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, RC_SIGN_IN,
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mShouldResolve = false;
}
}).show();
Log.d(TAG, "In ShowError");
} else {
Log.d(TAG, "Google Play Services Error:" + connectionResult);
Log.d(TAG, "In ShowError: " + apiAvailability.getErrorString(resultCode));
handleError("Play Services not supported");
mShouldResolve = false;
}
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.sign_in_button:
progressBar.setIndeterminate(true);
progressBar.setVisibility(View.VISIBLE);
if (!serviceUtils.checkInternet()) {
progressBar.setVisibility(View.INVISIBLE);
handleError("Connection Error");
} else {
mShouldResolve = true;
mGoogleApiClient.connect();
}
break;
}
}
private void registerUser() {
Log.d(TAG, "LoginActivity:RegisterUser:Url: " + Config.user_login_url);
StringRequest request = new StringRequest(Request.Method.POST,
Config.user_login_url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
SharedPreferences.Editor editor = sharedPreferences.edit();
try {
progressBar.setVisibility(View.INVISIBLE);
JSONObject json_response = new JSONObject(response);
Log.d(TAG, response.toString());
message = json_response.getString("message");
if (message.equals("Inserted successfully") || message.equals("ReLogin"))
editor.putString("userID", json_response.getString("UserID"));
editor.commit();
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("page", 0);
if (message.equals("ReLogin"))
intent.putExtra("newUser", 1);
if (message.equals("Inserted successfully"))
intent.putExtra("newUser", 0);
startActivity(intent);
GCMRegister();
} catch (JSONException e) {
e.printStackTrace();
Log.d(TAG, "LoginActivity:RegisterUser:JSONException:: " + e.getMessage());
handleError("Connection Error");
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "LoginActivity:RegisterUser:VolleyError: " + error.getMessage());
handleError("Connection Error");
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
Log.d(TAG, "LoginActivity:RegisterUser:Post:" + profileData.getEmail() + ", " + profileData.getPlatform() + "," + profileData.getFullName() + "," + profileData.getGender() + "," + profileData.getMaxAge()+","+profileData.getEmail()+","+profileData.getBirthday()+","+profileData.getProfileCoverUrl());
params.put("Email", profileData.getEmail());
params.put("LoginPlatform", profileData.getPlatform());
params.put("FullName", profileData.getFullName());
params.put("ProfilePic", profileData.getProfileImgUrl());
params.put("ProfileUrl", profileData.getPlatformProfileId());
params.put("ProfileCoverUrl",profileData.getProfileCoverUrl());
params.put("DOB", profileData.getBirthday());
params.put("Gender",profileData.getGender());
params.put("RelationshipStatus",profileData.getRelationshipStatus());
params.put("MaxAge",profileData.getMaxAge());
params.put("MinAge",profileData.getMinAge());
params.put("UserIsActive", String.valueOf(1));
params.put("UserDevice", "Android" + android.os.Build.VERSION.SDK_INT);
return params;
}
};
AppController.getInstance().addToRequestQueue(request);
}
private void GCMRegister() {
mRegistrationBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean sentToken = sharedPreferences.getBoolean(Config.SENT_TOKEN_TO_SERVER, false);
if (sentToken) {
Log.d(TAG, "register");
} else {
Log.d(TAG, "token error");
}
}
};
if (checkPlayServices()) {
Intent intent = new Intent(this, RegistrationIntentService.class);
startService(intent);
}
}
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
handleError("Play Services not supported");
}
return false;
}
return true;
}
@Override
public void onResume() {
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
mViewPager.setAdapter(new ImageSlideAdapter(this, "SignIn"));
mIndicator.setViewPager(mViewPager);
super.onResume();
}
private void handleError(String msg) {
progressBar.setVisibility(View.INVISIBLE);
if(msg.equals("Play Services not supported"))
{
Toast.makeText(this,"Play Services not supported",Toast.LENGTH_LONG).show();
}
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
}
}
最佳答案
检查您的 kitkat 设备的播放服务应用程序版本。
也许您应该使用旧版本的播放服务库。
在您的顶级 build.gradle 文件中:
classpath 'com.google.gms:google-services:1.3.0-beta1'
compile 'com.google.android.gms:play-services-plus:7.5.0'
compile "com.google.android.gms:play-services-gcm:7.5.0"
关于android - ConnectionResult=SERVICE_MISSING 用于 android Kitkat 真实设备中的 google play 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33968682/
所以我的应用程序的评论显示在我的游戏控制台中,但是由于某种原因,当我在 google Play 商店上访问我的应用程序链接并以普通用户的身份查看它时,我没有收到新评论的通知,我的显示了 13 条评论,
一旦我在 2.3 play 项目上运行 'sbt compile',我就不能再使用 'sbt compile' 来编译任何 Play 2.2.x 项目。这是我运行 sbt 命令时的错误。 [info]
我有点困惑,想得到一个解释。 我正在使用 Java Play 2 和 Akka Actor 。我使用 play run 启动系统。 不过,我刚刚看到一个视频,使用了命令: play akka star
当我玩游戏时,我遇到两个选择play.api.mvc和 play.mvc包裹 有什么不同? 最佳答案 从戏! 2 文档: The API available in the play.api packa
从 2.3 迁移到 2.4 后,我收到此错误。我应该使用的正确导入语句是什么? error: value routesImport is not a member of object play.Pla
所以我在 google play 上有一个应用程序已经将近 6 个月了,最近两个月我更新了我的应用程序屏幕截图,从那时起,每次我更新我的应用程序时,我都开始收到应用程序拒绝。 上次我提出上诉并被接受,
我有以下代码: Snapshots.OpenSnapshotResult result; result = Games.Snapshots.open(googleApiClient, "save",
在过去 72 小时内,我为 Google Play 开发者计划支付的 Google 电子钱包付款显示为“您的购买正在处理中”。我知道这可能需要长达 48 小时,但这是他们处理时间最坏情况之后的一整天。
我在 Play 商店发布了应用程序,我不知道为什么应用程序显示预注册,我想为我的用户提供直接下载选项。伸出援手将不胜感激。 最佳答案 instructions for pre-registration
我有一个 PHP 后端,它与 Google Play 服务集成以验证从 APP 进行的购买。购买信息返回收据和签名,我需要验证购买是否正确。 我收到: { ...rest of the data
我在 Google Play Developer Console 上创建了我的 Android 应用程序的草稿。我已经填写了所有需要的信息。必需的步骤之一是“内容评级”。我已填写表格以自动分配 Goo
我已经设置好了 com.typesafe.play play_2.13 2.7.4 在项目 pom.xml 中。但是,当我尝试遵循this tutorial时,语句 pla
我在 Play 商店上发布了一个应用程序,并收到了一些评论。在Google Play开发者控制台中,我在一些评论中看不到应用程序的版本。这是我在“应用程序”标题下找到的内容。 版本代码 — 版本名称
假设 A 是所有者。我希望我们团队的 B、C 和 D 用户能够上传我们应用程序的新版本。这可能吗?来自 this我不太清楚用户有什么样的权限。如果有人对这部分有任何经验,欢迎。 最佳答案 您需要 go
我正在尝试将应用重新提交到 Google Play,但我似乎可以找到一种技术上的方法来实现此目的。 我对“您的应用主要针对 COPPA 定义的 13 岁以下 child 吗?”的回答是肯定的,然后在不
我想分享一下我在分析 Google Play 控制台的新功能时遇到的情况,并尝试找到解决方案。 正如你们许多人可能已经知道的那样,Google 已在 Google Play 控制台上发布了更新并引入了
我有两个用 playframework 编写的应用程序。我想加入另一个。我有一个数据库,我想在它们之间共享我的登录类。应用程序对类、方法、变量使用不同的名称。 我怎样才能实现它?我应该创建 jar 版
对于我的硕士论文,我需要自动将来自 Google Play 的不同 Android 应用程序的信息写入一个文本文件。所以我使用 perl 脚本语言来实现这种自动化。我的 perl 脚本可以在 Goog
我想测试子项目是如何工作的,尤其是 routes在主项目 ( this was not visible before ) 中考虑了子项目的数量。 我在这里阅读了文档: https://github.c
我正在使用 Play 框架 2.1.2,我有一个 handlere 方法返回一个 Promise,如 Play 的 2.1.2 documentation 中所述 但是 Play 抛出编译错误说: C
我是一名优秀的程序员,十分优秀!