本文整理汇总了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);
}
}
}
};
}
示例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);
}
}
};
}
示例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);
}
}
}
};
}
示例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();
}
示例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();
}
示例6: consumeAsync
import com.android.vending.billing.util.Purchase; //导入依赖的package包/类
public void consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) {
mHelper.consumeAsync(purchase, listener);
}