本文整理汇总了Java中com.vk.sdk.VKUIHelper.getTopActivity方法的典型用法代码示例。如果您正苦于以下问题:Java VKUIHelper.getTopActivity方法的具体用法?Java VKUIHelper.getTopActivity怎么用?Java VKUIHelper.getTopActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vk.sdk.VKUIHelper
的用法示例。
在下文中一共展示了VKUIHelper.getTopActivity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCommonError
import com.vk.sdk.VKUIHelper; //导入方法依赖的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;
}
示例2: getTmpFile
import com.vk.sdk.VKUIHelper; //导入方法依赖的package包/类
public File getTmpFile() {
Context ctx = VKUIHelper.getTopActivity();
File outputDir = null;
if (ctx != null) {
outputDir = ctx.getExternalCacheDir();
if (outputDir == null)
outputDir = ctx.getCacheDir();
}
File tmpFile = null;
try {
tmpFile = File.createTempFile("tmpImg", String.format(".%s", mParameters.fileExtension()), outputDir);
FileOutputStream fos = new FileOutputStream(tmpFile);
if (mParameters.mImageType == VKImageParameters.VKImageType.Png)
mImageData.compress(Bitmap.CompressFormat.PNG, 100, fos);
else
mImageData.compress(Bitmap.CompressFormat.JPEG, (int) (mParameters.mJpegQuality * 100), fos);
fos.close();
} catch (IOException ignored) {
if (VKSdk.DEBUG)
ignored.printStackTrace();
}
return tmpFile;
}
示例3: processCommonError
import com.vk.sdk.VKUIHelper; //导入方法依赖的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;
}
示例4: getClient
import com.vk.sdk.VKUIHelper; //导入方法依赖的package包/类
/**
* Creates the http client (if need). Returns reusing client
*
* @return Prepared client used for API requests loading
*/
public static VKHttpClient getClient() {
if (sInstance == null) {
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https",
SSLSocketFactory.getSocketFactory(), 443));
HttpParams params = new BasicHttpParams();
Context ctx = VKUIHelper.getTopActivity();
try {
if (ctx != null)
{
PackageManager packageManager = ctx.getPackageManager();
if (packageManager != null) {
PackageInfo info = packageManager.getPackageInfo(ctx.getPackageName(), 0);
params.setParameter(CoreProtocolPNames.USER_AGENT,
String.format(Locale.US,
"%s/%s (%s; Android %d; Scale/%.2f; VK SDK %s; %s)",
VKUtil.getApplicationName(ctx), info.versionName,
Build.MODEL, Build.VERSION.SDK_INT,
ctx.getResources().getDisplayMetrics().density,
VKSdkVersion.SDK_VERSION,
info.packageName));
}
}
} catch (Exception ignored) {
}
sInstance = new VKHttpClient(new ThreadSafeClientConnManager(params, schemeRegistry),
params);
}
return sInstance;
}