当前位置: 首页>>代码示例>>Java>>正文


Java VKAccessToken类代码示例

本文整理汇总了Java中com.vk.sdk.VKAccessToken的典型用法代码示例。如果您正苦于以下问题:Java VKAccessToken类的具体用法?Java VKAccessToken怎么用?Java VKAccessToken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VKAccessToken类属于com.vk.sdk包,在下文中一共展示了VKAccessToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    mTwitterAuthClient.onActivityResult(requestCode, resultCode, data);
    if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(VKAccessToken token) {
            initUIAfterLogin();
        }

        @Override
        public void onError(VKError error) {
        }
    })) {
        super.onActivityResult(requestCode, resultCode, data);
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:19,代码来源:FragmentProfile.java

示例2: onActivityResult

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
@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 ) {
			AIR.log( "AuthFunction::onActivityResult | VK_AUTH_SUCCESS" );
			AIR.dispatchEvent( AIRVKEvent.VK_AUTH_SUCCESS, VKAccessTokenUtils.toJSON( res ) );
		}

		@Override
		public void onError( VKError error ) {
			AIR.log( "AuthFunction::onActivityResult | VK_AUTH_ERROR: " + error.errorMessage + " reason: " + error.errorReason );
			AIR.dispatchEvent( AIRVKEvent.VK_AUTH_ERROR, (error.errorMessage == null) ? "Error - user denied access." : error.errorMessage );
		}
	} ) ) {
		AIR.log( "AuthFunction::onActivityResult | no callback" );
	}
	AndroidActivityWrapper.GetAndroidActivityWrapper().removeActivityResultListener( this );
}
 
开发者ID:marpies,项目名称:vk-ane,代码行数:20,代码来源:AuthFunction.java

示例3: onActivityResult

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
@Override
protected void onActivityResult(final int requestCode, int resultCode, Intent data) {
    if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(final VKAccessToken accessToken) {
            createUserComponentAndLaunchMainActivity();
        }

        @Override
        public void onError(VKError error) {
            new AlertDialog.Builder(LoginActivity.this)
                    .setMessage("Login failed: " + error.errorReason)
                    .setPositiveButton(android.R.string.ok, null)
                    .show();
        }
    })) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:Mavamaarten,项目名称:vk_music_android,代码行数:20,代码来源:LoginActivity.java

示例4: onActivityResult

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
@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.i(LOG_TAG, "VKAccessToken: " + res);
            // User passed Authorization
            loadUser("onActivityResult");
        }
        @Override
        public void onError(VKError error) {
            // User didn't pass Authorization
            Log.e(LOG_TAG, "onActivityResult.onError: " + error);
        }
    })) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:DmitriyG1,项目名称:vk-music-player-android,代码行数:19,代码来源:LoginActivity.java

示例5: onReceiveNewToken

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
@Override
public void onReceiveNewToken(VKAccessToken newToken) {
    super.onReceiveNewToken(newToken);
    newToken.saveTokenToSharedPreferences(getActivity(), "VK_ACCESS_TOKEN");

    VKRequest request = VKApi.users().get(VKParameters.from(VKApiConst.FIELDS, "photo_200"));
    request.executeWithListener(new VKRequest.VKRequestListener() {
        @Override
        public void onComplete(VKResponse response) {
            super.onComplete(response);

            VKList<VKApiUserFull> vkList = (VKList<VKApiUserFull>) response.parsedModel;
            VKApiUserFull user = vkList.get(0);
            saveUserData(
                    user.first_name + " " + user.last_name,
                    user.photo_200
            );
            ((BaseSocialActivity) getActivity()).setLoginStatus(true, Const.SocialNetworks.VK_ID);
            moveToProfile();
        }
    });
    Log.d(LOG_TAG, "New User Token received");
}
 
开发者ID:CheDream-Android,项目名称:CheDream,代码行数:24,代码来源:LoginFragment.java

示例6: processCommonError

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
private boolean processCommonError(VKError error) {
    if (error.errorCode == VKError.VK_API_ERROR) {
        if (error.apiError.errorCode == 14) {
            error.apiError.request = this;
            this.mLoadingOperation = null;
            VKSdk.instance().sdkListener().onCaptchaError(error.apiError);
            return true;
        } else if (error.apiError.errorCode == 16) {
            VKAccessToken token = VKSdk.getAccessToken();
            token.httpsRequired = true;
            repeat();
            return true;
        } else if (error.apiError.errorCode == 17) {
         Intent i = new Intent(VKUIHelper.getTopActivity(), VKOpenAuthActivity.class);
         i.putExtra(VKOpenAuthActivity.VK_EXTRA_VALIDATION_URL, error.apiError.redirectUri);
            i.putExtra(VKOpenAuthActivity.VK_EXTRA_VALIDATION_REQUEST, this.registerObject());
VKUIHelper.getTopActivity().startActivityForResult(i, VKSdk.VK_SDK_REQUEST_CODE);
            return true;
        }
    }

    return false;
}
 
开发者ID:DementorAl,项目名称:VkAdmin,代码行数:24,代码来源:VKRequest.java

示例7: processCommonError

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
private boolean processCommonError(VKError error) {
    if (error.errorCode == VKError.VK_API_ERROR) {
        if (error.apiError.errorCode == 14) {
            error.apiError.request = this;
            this.mLoadingOperation = null;
            VKSdk.instance().sdkListener().onCaptchaError(error.apiError);
            return true;
        } else if (error.apiError.errorCode == 16) {
            VKAccessToken token = VKSdk.getAccessToken();
            token.httpsRequired = true;
            repeat();
            return true;
        } else if (error.apiError.errorCode == 17) {
         Intent i = new Intent(VKUIHelper.getTopActivity(), VKOpenAuthActivity.class);
         i.putExtra(VKOpenAuthActivity.VK_EXTRA_VALIDATION_URL, error.apiError.redirectUri);
VKUIHelper.getTopActivity().startActivityForResult(i, VKSdk.VK_SDK_REQUEST_CODE);
            return true;
        }
    }

    return false;
}
 
开发者ID:LizaAlert-HotLine,项目名称:AndroidMobileWorkplace,代码行数:23,代码来源:VKRequest.java

示例8: onActivityResult

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    VKCallback<VKAccessToken> callback = new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(VKAccessToken res) {
            // User passed Authorization
            startTestActivity();
        }

        @Override
        public void onError(VKError error) {
            // User didn't pass Authorization
        }
    };

    if (!VKSdk.onActivityResult(requestCode, resultCode, data, callback)) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:VKCOM,项目名称:vk-android-sdk,代码行数:20,代码来源:LoginActivity.java

示例9: initVkontakte

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
private void initVkontakte() {
    VKAccessTokenTracker vkAccessTokenTracker = new VKAccessTokenTracker() {
        @Override
        public void onVKAccessTokenChanged(VKAccessToken oldToken, VKAccessToken newToken) {
            if (newToken == null) {
            }
        }
    };
    vkAccessTokenTracker.startTracking();
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:11,代码来源:LoginMaster.java

示例10: getToken

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
public String getToken() {
    if (Prefs.getString(SyncMaster.GLOBAL_TOKEN, null) != null) {
        return Prefs.getString(SyncMaster.GLOBAL_TOKEN, null);
    } else if (AccessToken.getCurrentAccessToken() != null)
        return AccessToken.getCurrentAccessToken().getToken();
    else if (Twitter.getSessionManager().getActiveSession() != null) {
        TwitterSession session = Twitter.getSessionManager().getActiveSession();
        TwitterAuthToken authToken = session.getAuthToken();
        return authToken.token;
    } else
        return VKAccessToken.currentToken().accessToken;
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:13,代码来源:LoginMaster.java

示例11: requestWithVkRequest

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
/**
 * Prepares new "normal" request from VKRequest
 *
 * @param vkRequest Request, created for some method
 * @return Prepared request for creating VKHttpOperation
 */
public static VKHTTPRequest requestWithVkRequest(@NonNull VKRequest vkRequest) {
    VKAccessToken token = VKAccessToken.currentToken();
    VKHTTPRequest result = new VKHTTPRequest(String.format(Locale.US, "http%s://api.vk.com/method/%s", vkRequest.secure || (token != null && token.httpsRequired) ? "s" : "", vkRequest.methodName));
    result.headers = getDefaultHeaders();
    result.setVkParameters(vkRequest.getPreparedParameters());
    return result;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:14,代码来源:VKHttpClient.java

示例12: getPreparedParameters

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
public VKParameters getPreparedParameters() {
    if (mPreparedParameters == null) {
        mPreparedParameters = new VKParameters(mMethodParameters);

        //Set current access token from SDK object
        VKAccessToken token = VKAccessToken.currentToken();
        if (token != null) {
            mPreparedParameters.put(VKApiConst.ACCESS_TOKEN, token.accessToken);
            if (token.httpsRequired) {
                this.secure = true;
            }
        }
        //Set actual version of API
        mPreparedParameters.put(VKApiConst.VERSION, VKSdk.getApiVersion());
        //Set preferred language for request
        mPreparedParameters.put(VKApiConst.LANG, getLang());

        if (this.secure) {
            //If request is secure, we need all urls as https
            mPreparedParameters.put(VKApiConst.HTTPS, "1");
        }
        if (token != null && token.secret != null) {
            //If it not, generate signature of request
            String sig = generateSig(token);
            mPreparedParameters.put(VKApiConst.SIG, sig);
        }
        //From that moment you cannot modify parameters.
        //Specially for http loading
    }
    return mPreparedParameters;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:32,代码来源:VKRequest.java

示例13: generateSig

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
private String generateSig(VKAccessToken token) {
    //Read description here https://vk.com/dev/api_nohttps
    //At first, we need key-value pairs in order of request
    String queryString = VKStringJoiner.joinParams(mPreparedParameters);
    //Then we generate "request string" /method/{METHOD_NAME}?{GET_PARAMS}{POST_PARAMS}
    queryString = String.format(Locale.US, "/method/%s?%s", methodName, queryString);
    return VKUtil.md5(queryString + token.secret);

}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:10,代码来源:VKRequest.java

示例14: processCommonError

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
private boolean processCommonError(final VKError error) {
    //TODO: lock thread, if ui required, release then
    if (error.errorCode == VKError.VK_API_ERROR) {
        final VKError apiError = error.apiError;

        VKSdk.notifySdkAboutApiError(apiError);

        if (apiError.errorCode == 16) {
            VKAccessToken token = VKAccessToken.currentToken();
            if (token != null) {
                token.httpsRequired = true;
                token.save();
            }
            repeat();

            return true;
        } else if (shouldInterruptUI) {
            apiError.request = this;
            if (error.apiError.errorCode == 14) {
                this.mLoadingOperation = null;
                VKServiceActivity.interruptWithError(context, apiError, VKServiceActivity.VKServiceType.Captcha);
                return true;
            } else if (apiError.errorCode == 17) {
                VKServiceActivity.interruptWithError(context, apiError, VKServiceActivity.VKServiceType.Validation);
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:32,代码来源:VKRequest.java

示例15: toJSON

import com.vk.sdk.VKAccessToken; //导入依赖的package包/类
public static String toJSON( VKAccessToken token ) {
	if( token.userId == null ) return null;

	JSONObject json = new JSONObject();
	addValueForKey( token.userId, "userId", json );
	addValueForKey( token.accessToken, "accessToken", json );
	addValueForKey( token.secret, "secret", json );
	addValueForKey( token.email, "email", json );
	addValueForKey( token.expiresIn, "expiresIn", json );
	addValueForKey( token.created, "created", json );
	addValueForKey( token.httpsRequired, "httpsRequired", json );
	/* Loop through all permissions and see which one are part of this token */
	List<String> allPermissions = VKScope.parseVkPermissionsFromInteger( Integer.MAX_VALUE );	// Get all permissions
	JSONArray activePermissions = new JSONArray();
	/* VKAcessToken's scope may be null, however, it's not
	 * accessible directly so we have to wrap it in try-catch block */
	try {
		for( String permission : allPermissions ) {
			if( token.hasScope( permission ) ) {
				activePermissions.put( permission );
			}
		}
	} catch( Exception e ) {
		// VKAccessToken's 'scope' is null, thus no permissions
	}
	addValueForKey( activePermissions.toString(), "permissions", json );
	return json.toString();
}
 
开发者ID:marpies,项目名称:vk-ane,代码行数:29,代码来源:VKAccessTokenUtils.java


注:本文中的com.vk.sdk.VKAccessToken类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。