本文整理汇总了Java中com.vk.sdk.VKAccessToken.currentToken方法的典型用法代码示例。如果您正苦于以下问题:Java VKAccessToken.currentToken方法的具体用法?Java VKAccessToken.currentToken怎么用?Java VKAccessToken.currentToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vk.sdk.VKAccessToken
的用法示例。
在下文中一共展示了VKAccessToken.currentToken方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: onReceiveStatic
import com.vk.sdk.VKAccessToken; //导入方法依赖的package包/类
private static void onReceiveStatic(final Context ctx, boolean forceOurUser) {
if (isActiveNetwork(ctx) && VKSdk.isIsPaymentsEnable()) {
if (VKAccessToken.currentToken() == null && !tracker.isTracking()) {
tracker.startTracking();
}
checkUserInstall(ctx, forceOurUser);
}
}
示例6: updateMenuStatus
import com.vk.sdk.VKAccessToken; //导入方法依赖的package包/类
private void updateMenuStatus() {
if (optionsMenu == null) {
return;
}
boolean isLoggedIn = VKAccessToken.currentToken() != null;
optionsMenu.findItem(R.id.menuItemLogin).setEnabled(!isLoggedIn);
optionsMenu.findItem(R.id.menuItemLoadBeginning).setEnabled(isLoggedIn);
optionsMenu.findItem(R.id.menuItemLogout).setEnabled(isLoggedIn);
}