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


Java VKUIHelper.getTopActivity方法代码示例

本文整理汇总了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;
}
 
开发者ID:DementorAl,项目名称:VkAdmin,代码行数:24,代码来源:VKRequest.java

示例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;
}
 
开发者ID:DementorAl,项目名称:VkAdmin,代码行数:24,代码来源:VKUploadImage.java

示例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;
}
 
开发者ID:LizaAlert-HotLine,项目名称:AndroidMobileWorkplace,代码行数:23,代码来源:VKRequest.java

示例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;
}
 
开发者ID:DementorAl,项目名称:VkAdmin,代码行数:39,代码来源:VKHttpClient.java


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