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


Java Purchase类代码示例

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


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

示例1: initPurchaseListener

import com.android.vending.billing.util.Purchase; //导入依赖的package包/类
/**
 * init purchase listener for async purchase request
 */
private void initPurchaseListener() {
    mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
        @Override
        public void onIabPurchaseFinished(IabResult result, Purchase info) {
            // if we were disposed of in the meantime, quit.
            if (mIabHelper == null) return;

            //if success, thanks the user
            if (result.isSuccess()) {
                purchaseSuccess(info);
            } else if (result.getResponse() == IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
                //if purchase already owned consume it
                if (mPurchaseList.get(mSelectedPurchase) != null) {
                    //workaround to get the purchase since info == null when already owned
                    mIabHelper.consumeAsync(mPurchaseList.get(mSelectedPurchase), mConsumeListener);
                }
            }
        }
    };
}
 
开发者ID:tvbarthel,项目名称:CameraColorPicker,代码行数:24,代码来源:SupportActivity.java

示例2: initConsumeListener

import com.android.vending.billing.util.Purchase; //导入依赖的package包/类
/**
 * init callback for purchase consumption when purchase is already owned
 */
private void initConsumeListener() {
    mConsumeListener = new IabHelper.OnConsumeFinishedListener() {
        @Override
        public void onConsumeFinished(Purchase purchase, IabResult result) {
            //if consume or not owned (due to cache from API v3, not owned purchase can be
            // asked for consumption) buy product again
            if (result.isSuccess() ||
                    result.getResponse() == IabHelper.BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED) {
                mIabHelper.launchPurchaseFlow(SupportActivity.this,
                        purchase.getSku(),
                        SupportUtils.REQUEST_CODE_SUPPORT_DEV,
                        mPurchaseFinishedListener);
            }
        }
    };
}
 
开发者ID:tvbarthel,项目名称:CameraColorPicker,代码行数:20,代码来源:SupportActivity.java

示例3: initPurchaseListener

import com.android.vending.billing.util.Purchase; //导入依赖的package包/类
/**
 * init purchase listener for async purchase request
 */
private void initPurchaseListener() {
    mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
        @Override
        public void onIabPurchaseFinished(IabResult result, Purchase info) {

            // if we were disposed of in the meantime, quit.
            if (mIabHelper == null) return;

            //if success, thanks the user
            if (result.isSuccess()) {
                purchaseSuccess(info);
            } else if (result.getResponse() == IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
                //if purchase already owned consume it
                if (mPurchaseList.get(mSelectedPurchase) != null) {
                    //workaround to get the purchase since info == null when already owned
                    mIabHelper.consumeAsync(mPurchaseList.get(mSelectedPurchase), mConsumeListener);
                }
            }
        }
    };
}
 
开发者ID:tvbarthel,项目名称:SimpleWeatherForecast,代码行数:25,代码来源:SupportActivity.java

示例4: purchaseSuccess

import com.android.vending.billing.util.Purchase; //导入依赖的package包/类
/**
 * dialog to thanks user for his support
 */
private void purchaseSuccess(Purchase info) {
    AlertDialog.Builder build = new AlertDialog.Builder(this);
    build.setPositiveButton(R.string.support_thanks_positive_btn, null);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View thanksView = inflater.inflate(R.layout.support_thanks, null);
    if (thanksView != null) {
        final TextView thanksMessage =
                (TextView) thanksView.findViewById(R.id.support_thanks_message);
        thanksMessage.setText(String.format(
                getResources().getString(R.string.support_thanks), info.getSku()));
        build.setView(thanksView);
        build.create().show();
    }

    //save support act in shared preferences
    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    final SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putInt(SupportUtils.SUPPORT_SHARED_KEY, SupportUtils.SUPPORT_DONATE);
    editor.commit();
}
 
开发者ID:tvbarthel,项目名称:SimpleWeatherForecast,代码行数:24,代码来源:SupportActivity.java

示例5: purchaseSuccess

import com.android.vending.billing.util.Purchase; //导入依赖的package包/类
/**
 * dialog to thanks user for his support
 */
private void purchaseSuccess(Purchase info) {
    AlertDialog.Builder build = new AlertDialog.Builder(this);
    build.setMessage(String.format(
            getResources().getString(R.string.support_thanks), info.getSku()));
    build.setPositiveButton(R.string.support_thanks_positive_btn, null);
    build.create().show();

    //save support act in shared preferences
    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    final SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putInt(SupportUtils.SUPPORT_SHARED_KEY, SupportUtils.SUPPORT_DONATE);
    editor.commit();
}
 
开发者ID:tvbarthel,项目名称:CameraColorPicker,代码行数:17,代码来源:SupportActivity.java

示例6: consumeAsync

import com.android.vending.billing.util.Purchase; //导入依赖的package包/类
public void consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) {
	mHelper.consumeAsync(purchase, listener);
}
 
开发者ID:laurion,项目名称:wabbit-client,代码行数:4,代码来源:BillingHelper.java


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