@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (!VKSdk.onActivityResult( requestCode, resultCode, data, new VKCallback<VKAccessToken>() { @Override public void onResult(VKAccessToken res) { Log.d(LOG_T, "Successfully logged in"); Intent intent = new Intent(); intent.putExtra("result", "LoggedIN"); setResult(RESULT_OK, intent); finish(); } @Override public void onError(VKError error) { Log.d(LOG_T, "Error"); Intent intent = new Intent(); intent.putExtra("result", "ERROR"); setResult(RESULT_CANCELED, intent); finish(); } })) { super.onActivityResult(requestCode, resultCode, data); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (!VKSdk.onActivityResult( requestCode, resultCode, data, new VKCallback<VKAccessToken>() { @Override public void onResult(VKAccessToken res) { // Пользователь успешно авторизовался userID = res.userId; Log.d(LOG_TAG, " onResult"); final Bitmap photo = mBitmap; VKRequest request2 = VKApi.uploadWallPhotoRequest( new VKUploadImage(photo, VKImageParameters.jpgImage(0.9f)), 0, 0); request2.executeWithListener( new VKRequest.VKRequestListener() { @Override public void onComplete(VKResponse response) { photo.recycle(); VKApiPhoto photoModel = ((VKPhotoArray) response.parsedModel).get(0); // Make post with photo Log.d(LOG_TAG, " photoModel.getId() = " + photoModel.getId()); makePost( new VKAttachments(photoModel), mCharacter.getName() + "\n" + mCharacter.getDescription()); Log.d(LOG_TAG, " onComplete"); } @Override public void onError(VKError error) { Log.d(LOG_TAG, " onError"); } }); } @Override public void onError(VKError error) { // Произошла ошибка авторизации (например, пользователь запретил авторизацию) Log.d(LOG_TAG, " VKError onError"); } })) { super.onActivityResult(requestCode, resultCode, data); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == VKServiceActivity.VKServiceType.Authorization.getOuterCode() || requestCode == VKServiceActivity.VKServiceType.Validation.getOuterCode() && resultCode == Activity.RESULT_OK) { ((MainActivity) getActivity()).replaceFragment(new MainFragment(), false); return; } if (data == null) { super.onActivityResult(requestCode, resultCode, null); return; } if (!VKSdk.onActivityResult( requestCode, resultCode, data, new VKCallback<VKAccessToken>() { @Override public void onResult(VKAccessToken res) { // Toast.makeText(getActivity(), "Login success", Toast.LENGTH_SHORT).show(); // btnLogin.setVisibility(View.GONE); // TODO: 11/5/15 need to catch login result and // hide login button } @Override public void onError(VKError error) { Toast.makeText( getActivity(), String.format("Login error: %s", error.errorMessage), Toast.LENGTH_LONG) .show(); } })) { super.onActivityResult(requestCode, resultCode, data); } }