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


Java VKUIHelper.getApplicationContext方法代码示例

本文整理汇总了Java中com.vk.sdk.VKUIHelper.getApplicationContext方法的典型用法代码示例。如果您正苦于以下问题:Java VKUIHelper.getApplicationContext方法的具体用法?Java VKUIHelper.getApplicationContext怎么用?Java VKUIHelper.getApplicationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vk.sdk.VKUIHelper的用法示例。


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

示例1: VKRequest

import com.vk.sdk.VKUIHelper; //导入方法依赖的package包/类
/**
 * Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods
 *
 * @param method     API-method name, e.g. audio.get
 * @param parameters method parameters
 * @param modelClass class for automatic parse
 */
public VKRequest(String method, VKParameters parameters, Class<? extends VKApiModel> modelClass) {
    this.context = VKUIHelper.getApplicationContext();

    this.methodName = method;
    if (parameters == null) {
        parameters = new VKParameters();
    }
    this.mMethodParameters = new VKParameters(parameters);
    this.mAttemptsUsed = 0;

    this.secure = true;
    //By default there is 1 attempt for loading.
    this.attempts = 1;

    //If system language is not supported, we use english
    this.mPreferredLang = "en";
    //By default we use system language.
    this.useSystemLanguage = true;

    this.shouldInterruptUI = true;

    setModelClass(modelClass);
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:31,代码来源:VKRequest.java

示例2: getTmpFile

import com.vk.sdk.VKUIHelper; //导入方法依赖的package包/类
public File getTmpFile() {
    Context ctx = VKUIHelper.getApplicationContext();
    File outputDir = null;
    if (ctx != null) {
        outputDir = ctx.getExternalCacheDir();
        if (outputDir == null || !outputDir.canWrite())
            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:DESTROYED,项目名称:The_busy_calendar,代码行数:24,代码来源:VKUploadImage.java

示例3: consumePurchase

import com.vk.sdk.VKUIHelper; //导入方法依赖的package包/类
/**
 * Consume the last purchase of the given SKU. This will result in this item being removed
 * from all subsequent responses to getPurchases() and allow re-purchase of this item.
 *
 * @param apiVersion    billing API version that the app is using
 * @param packageName   package name of the calling app
 * @param purchaseToken token in the purchase information JSON that identifies the purchase
 *                      to be consumed
 * @return 0 if consumption succeeded. Appropriate error values for failures.
 */
public int consumePurchase(final int apiVersion,
                           @NonNull final String packageName,
                           @NonNull final String purchaseToken) throws android.os.RemoteException {
    String purchaseData = !VKPaymentsServerSender.isNotVkUser() //
            ? getPurchaseData(mIInAppBillingService, apiVersion, packageName, purchaseToken) //
            : null;

    int result;
    try {
        result = (Integer) sMethodConsumePurchase.invoke(mIInAppBillingService, apiVersion, packageName, purchaseToken);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    final Context ctx = VKUIHelper.getApplicationContext();
    if (!TextUtils.isEmpty(purchaseData) && ctx != null) {
        VKPaymentsServerSender.getInstance(ctx).saveTransaction(purchaseData);
    }

    return result;
}
 
开发者ID:marpies,项目名称:vk-ane,代码行数:32,代码来源:VKIInAppBillingService.java

示例4: isNotVkUser

import com.vk.sdk.VKUIHelper; //导入方法依赖的package包/类
public static boolean isNotVkUser() {
    if (!VKSdk.isIsPaymentsEnable()) {
        return true;
    }
    final Context ctx = VKUIHelper.getApplicationContext();
    return ctx != null && VKPaymentsServerSender.getInstance(ctx).mCheckUserInstallAnswer == CHECK_USER_INSTALL_ANSWER_NOT_VK;
}
 
开发者ID:marpies,项目名称:vk-ane,代码行数:8,代码来源:VKPaymentsServerSender.java

示例5: createConnection

import com.vk.sdk.VKUIHelper; //导入方法依赖的package包/类
HttpURLConnection createConnection() throws IOException {
    URL url = this.methodUrl;
    this.connection = (HttpURLConnection) url.openConnection();

    this.connection.setReadTimeout(this.timeout);
    this.connection.setConnectTimeout(this.timeout + 5000);
    this.connection.setRequestMethod("POST");
    this.connection.setUseCaches(false);
    this.connection.setDoInput(true);
    this.connection.setDoOutput(true);

    try {
        Context ctx = VKUIHelper.getApplicationContext();
        if (ctx != null) {
            PackageManager packageManager = ctx.getPackageManager();
            if (packageManager != null) {
                PackageInfo info = packageManager.getPackageInfo(ctx.getPackageName(), 0);
                this.connection.setRequestProperty("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) {
    }

    this.connection.setRequestProperty("Connection", "Keep-Alive");
    if (this.headers != null) {
        for (Map.Entry<String, String> entry : this.headers.entrySet()) {
            this.connection.addRequestProperty(entry.getKey(), entry.getValue());
        }
    }

    if (this.entity != null) {
        this.connection.addRequestProperty("Content-length", this.entity.getContentLength() + "");
        Pair<String, String> contentType = this.entity.getContentType();
        this.connection.addRequestProperty(contentType.first, contentType.second);
    }

    OutputStream os = this.connection.getOutputStream();
    this.writeParams(os);
    os.close();

    this.connection.connect();

    return this.connection;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:52,代码来源:VKHttpClient.java


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