{"action":"created","issue":{"url":"https://api.github.com/repos/Aeonitis/lh-and/issues/33","repository_url":"https://api.github.com/repos/Aeonitis/lh-and","labels_url":"https://api.github.com/repos/Aeonitis/lh-and/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/Aeonitis/lh-and/issues/33/comments","events_url":"https://api.github.com/repos/Aeonitis/lh-and/issues/33/events","html_url":"https://github.com/Aeonitis/lh-and/issues/33","id":190395539,"number":33,"title":"GoogleSignInResult returned as Null (NullPointerException)","user":{"login":"Aeonitis","id":1273824,"avatar_url":"https://avatars.githubusercontent.com/u/1273824?v=3","gravatar_id":"","url":"https://api.github.com/users/Aeonitis","html_url":"https://github.com/Aeonitis","followers_url":"https://api.github.com/users/Aeonitis/followers","following_url":"https://api.github.com/users/Aeonitis/following{/other_user}","gists_url":"https://api.github.com/users/Aeonitis/gists{/gist_id}","starred_url":"https://api.github.com/users/Aeonitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aeonitis/subscriptions","organizations_url":"https://api.github.com/users/Aeonitis/orgs","repos_url":"https://api.github.com/users/Aeonitis/repos","events_url":"https://api.github.com/users/Aeonitis/events{/privacy}","received_events_url":"https://api.github.com/users/Aeonitis/received_events","type":"User","site_admin":false},"labels":[{"id":377338501,"url":"https://api.github.com/repos/Aeonitis/lh-and/labels/bug","name":"bug","color":"ee0701","default":true},{"id":377338506,"url":"https://api.github.com/repos/Aeonitis/lh-and/labels/question","name":"question","color":"0052cc","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-18T18:59:51Z","updated_at":"2016-11-22T16:48:26Z","closed_at":null,"body":"App v0.1.4\r\nError Log:\r\n\r\nFatal Exception: java.lang.RuntimeException\r\nFailure delivering result \r\nResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.lh.andx/com.lh.andx.LoginActivity}: java.lang.NullPointerException\r\n\r\nRaw Text\r\nandroid.app.ActivityThread.deliverResults (ActivityThread.java:3351)\r\ndalvik.system.NativeStart.main (NativeStart.java)\r\nCaused by java.lang.NullPointerException\r\ncom.lh.utils.AuthUtil.handleSignInResult (AuthUtil.java:42)\r\n**Code around line 42:**\r\n> `public static boolean handleSignInResult(Activity callingActivity, GoogleSignInResult result) {\r\n>         Log.d(TAG, \"handleSignInResult\");\r\n>         if (result.isSuccess()) {\r\n>             // Signed in successfully, show authenticated UI.\r\n>             GoogleSignInAccount acct = result.getSignInAccount();\r\n>             if (acct.getEmail() != null) {\r\n>                 /**\r\n>                 * Other code here...\r\n>                 */              \r\n>                 getGoogleOAuthTokenAndLogin(callingActivity, acct.getEmail());\r\n>                 // Signed in, show result updated UI...\r\n>                 return true;\r\n>             } else {\r\n>                 Log.e(TAG, \"UNEXPECTED ERROR/SCENARIO: combination of 'null account email' and 'result.isSuccess()' scenarios. please resolve!!!\");\r\n>                 return false;\r\n>             }\r\n>         } else {\r\n>             //TODO: Error status Code Handling through Analytics and LHError (Specific code for Google Auth fail)\r\n>             Log.e(TAG, \"handling SignInResult... Status:\" + result.getStatus().toString());\r\n>             // Signed out, show unauthenticated UI.\r\n>             return false;\r\n>         }\r\n>     }`\r\n> \r\n\r\ncom.lh.andx.LoginActivity.onActivityResult (LoginActivity.java:117)\r\n**Code around line 117 (null check now added to monitor case):**\r\n`protected void onActivityResult(int requestCode, int resultCode, Intent data) {\r\n        super.onActivityResult(requestCode, resultCode, data);\r\n        Log.d(TAG, \"onActivityResult - Checking Request Code...\");\r\n        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);\r\n        if (requestCode == REQUEST_CODE_GOOGLE_AUTH_SIGN_IN) {\r\n            Log.d(TAG, \"onActivityResult - \" + requestCode +\"|\"+ resultCode +\"|\"+ data);\r\n            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);\r\n            if(result!=null) {\r\n                CrashUtil.logCustomUserEvent(\"Login - Available GoogleSignInResult\", \"\");\r\n                if (AuthUtil.handleSignInResult(this, result)) {\r\n                    //Fetching user data manually - second case scenario for user login\r\n                    logInToServer(UserPreference.getUserID(this));\r\n                }\r\n            } else {\r\n                Log.e(TAG, getString(R.string.login_null_googlesigninresult));\r\n                CrashUtil.logCustomUserEvent(\"Login - Null GoogleSignInResult\", \"\");\r\n                Toast.makeText(this,getString(R.string.login_null_googlesigninresult), Toast.LENGTH_LONG).show();\r\n            }\r\n        }\r\n        if (requestCode == LHConstants.PERM_REQUEST_CODE_DRAW_OVERLAYS) {\r\n            if (android.os.Build.VERSION.SDK_INT >= 23) {   //Android M Or Over\r\n                if (!Settings.canDrawOverlays(this)) {\r\n                    Log.i(TAG, \"onActivityResult - permission 'PERM_REQUEST_CODE_DRAW_OVERLAYS' NOT granted by user...\");\r\n                    Toast.makeText(this, getString(R.string.permission_denied_by_user_draw_overlays), Toast.LENGTH_LONG).show();\r\n                    finish();\r\n                    // TODO: UI for SYSTEM_ALERT_WINDOW permission not granted...\r\n                } else {\r\n                    Log.i(TAG, \"onActivityResult - permission 'PERM_REQUEST_CODE_DRAW_OVERLAYS' granted by user...\");\r\n                }\r\n            }\r\n        }\r\n    }`\r\n\r\nandroid.app.Activity.dispatchActivityResult (Activity.java:5423)\r\ndalvik.system.NativeStart.main (NativeStart.java)"},"comment":{"url":"https://api.github.com/repos/Aeonitis/lh-and/issues/comments/262295564","html_url":"https://github.com/Aeonitis/lh-and/issues/33#issuecomment-262295564","issue_url":"https://api.github.com/repos/Aeonitis/lh-and/issues/33","id":262295564,"user":{"login":"Aeonitis","id":1273824,"avatar_url":"https://avatars.githubusercontent.com/u/1273824?v=3","gravatar_id":"","url":"https://api.github.com/users/Aeonitis","html_url":"https://github.com/Aeonitis","followers_url":"https://api.github.com/users/Aeonitis/followers","following_url":"https://api.github.com/users/Aeonitis/following{/other_user}","gists_url":"https://api.github.com/users/Aeonitis/gists{/gist_id}","starred_url":"https://api.github.com/users/Aeonitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aeonitis/subscriptions","organizations_url":"https://api.github.com/users/Aeonitis/orgs","repos_url":"https://api.github.com/users/Aeonitis/repos","events_url":"https://api.github.com/users/Aeonitis/events{/privacy}","received_events_url":"https://api.github.com/users/Aeonitis/received_events","type":"User","site_admin":false},"created_at":"2016-11-22T16:48:26Z","updated_at":"2016-11-22T16:48:26Z","body":"Check for Google Play Services version using http://stackoverflow.com/questions/18737632/how-to-check-google-play-services-version\r\n\r\nprivate boolean checkGooglePlayServices() {\r\n        final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);\r\n        if (status != ConnectionResult.SUCCESS) {\r\n            Log.e(TAG, GooglePlayServicesUtil.getErrorString(status));\r\n\r\n            // ask user to update google play services.\r\n            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, 1);\r\n            dialog.show();\r\n            return false;\r\n        } else {\r\n            Log.i(TAG, GooglePlayServicesUtil.getErrorString(status));\r\n            // google play services is updated. \r\n            //your code goes here...\r\n            return true;\r\n        }\r\n    }\r\n\r\nAlso, GOOGLE_PLAY_SERVICES_VERSION_CODE from https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability.html#GOOGLE_PLAY_SERVICES_VERSION_CODE may be what I need, seems like it gets the client library"}}
{"actor":{"display_login":"Aeonitis"}}