- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已按照 google GitHub example 在我的 Activity 中实现了应用内结算
这是我的代码:
public class Premium extends Activity implements IabBroadcastReceiver.IabBroadcastListener {
Button premium;
//toast
Context context = getBaseContext();
int duration = Toast.LENGTH_SHORT;
//debug tag
static final String TAG = "CHORDS";
//does the user have premium?
boolean mIsPremium = false;
//SKUs
static final String SKU_PREMIUM = "chords_premium";
// (arbitrary) request code for the purchase flow
static final int RC_REQUEST = 10001;
// The helper object
IabHelper mHelper;
// Provides purchase notification while this app is running
IabBroadcastReceiver mBroadcastReceiver;
public void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.premium_layout);
premium = (Button) findViewById(R.id.premium);
String base64EncodedPublicKey = "Key"
// Create the helper, passing it our context and the public key to verify signatures with
Log.d(TAG, "Creating IAB helper.");
mHelper = new IabHelper(this, base64EncodedPublicKey);
// Start setup. This is asynchronous and the specified listener
// will be called once setup completes.
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up in-app billing: " + result);
return;
}
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
mBroadcastReceiver = new IabBroadcastReceiver(Premium.this);
IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
registerReceiver(mBroadcastReceiver, broadcastFilter);
Log.d(TAG, "Setup successful. Querying inventory.");
try {
mHelper.queryInventoryAsync(mGotInventoryListener);
} catch (IabHelper.IabAsyncInProgressException e) {
Log.d(TAG, "Error querying inventory. Another async operation in progress.");
}
}
});
}
// Listener that's called when we finish querying the items and subscriptions we own
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// Is it a failure?
if (result.isFailure()) {
Log.d(TAG, "Failed to query inventory: " + result);
return;
}
Log.d(TAG, "Query inventory was successful.");
/*
* Check for items we own. Notice that for each purchase, we check
* the developer payload to see if it's correct! See
* verifyDeveloperPayload().
*/
// Do we have the premium upgrade?
Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
premium.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mIsPremium = true)
premium.setEnabled(false);
else {
}
}
});
};
};
@Override
public void receivedBroadcast() {
// Received a broadcast notification that the inventory of items has changed
Log.d(TAG, "Received broadcast notification. Querying inventory.");
try {
mHelper.queryInventoryAsync(mGotInventoryListener);
} catch (IabHelper.IabAsyncInProgressException e) {
Log.d(TAG, "Error querying inventory. Another async operation in progress.");
}
}
// User clicked the "Upgrade to Premium" button.
public void onUpgradeAppButtonClicked(View arg0) {
Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
/* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
String payload = "";
try {
mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, payload);
} catch (IabHelper.IabAsyncInProgressException e) {
Log.d(TAG,"Error launching purchase flow. Another async operation in progress.");
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
if (mHelper == null) return;
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
/** Verifies the developer payload of a purchase. */
boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();
return true;
}
// Callback for when a purchase is finished
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
// if we were disposed of in the meantime, quit.
if (mHelper == null) return;
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
return;
}
if (!verifyDeveloperPayload(purchase)) {
Log.d(TAG, "Error purchasing. Authenticity verification failed.");
return;
}
Log.d(TAG, "Purchase successful.");
if (purchase.getSku().equals(SKU_PREMIUM)) {
// bought the premium upgrade!
Log.d(TAG, "Purchase is premium upgrade. Congratulating user.");
Toast toast = Toast.makeText(context, R.string.premium_bought, duration);
toast.show();
mIsPremium = true;
updateUI();
}
}
};
// We're being destroyed. It's important to dispose of the helper here!
@Override
public void onDestroy() {
super.onDestroy();
// very important:
if (mBroadcastReceiver != null) {
unregisterReceiver(mBroadcastReceiver);
}
// very important:
Log.d(TAG, "Destroying helper.");
if (mHelper != null) {
mHelper.disposeWhenFinished();
mHelper = null;
}
}
public void updateUI() {
//TODO: elimina pubblicita
}
}
正如我在标题中所写,我需要启动 google purchase当我的高级按钮被按下时。 android 文档对于如何做这些事情不是很清楚。
我应该在 OnClick()
方法中添加什么来启动购买流程?
最佳答案
你应该打电话
mHelper.startSetup
单击按钮即可开始购买流程。
关于java - Android 应用内计费 : Start purchase flow when button is pressed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39407719/
我刚刚注意到 align-self 属性的一些值,这是我以前从未见过的。什么是start、end、self-start、self-end,它们与有什么区别>flex-start 和 flex-end?
我见过程序员使用公式 mid = start + (end - start) / 2 而不是使用更简单的公式 mid = (start + end) / 2 用于查找数组或列表中的中间元素。 为什么他
我们已经设置了一个小型 AZURE VM(由 Microsoft 提供的普通 Windows 2012 R2 镜像),其中包含一个轻量级 DEMO 应用程序,该应用程序可以与 SQLExpress 和
我在笔记本电脑上安装了Xampp 3.2.1版,之前MySQL在它上面运行得很好,但突然MySQL停止运行,而阿帕奇和其他公司都在运行。当我点击开始MySQL时,它显示这个错误我使用Windows 1
我希望我能解释清楚。 我有自动生成的代码,我希望用 CSS 覆盖它。 这是我希望覆盖的代码示例: #u1150:hover #u1153-4 p {color: red} 重要提示:此代码中的“u”将
在我的 package.json 中,我有以下脚本 block : "scripts": { "start": "react-scripts start",
https://github.com/lodash/lodash/blob/3.7.0/lodash.src.js#L2781 此代码段 start = start == null 中的 +start
上下文 我一直在阅读有关如何将 TUMBLINGWINDOW 函数与 TIMSTAMP BY 子句一起使用的文档,但似乎找不到有关如何计算包含 TUMBLING WINDOW 和 TIMESTAMP
我正在使用 Grunt 运行 Protractor 端到端测试用例。我有以下三个任务(我使用的是 windows 7 机器) webdriver-stop webdriver-start Protra
我正在创建一个简单的Java程序,它具有在窗口生成器的帮助下构建的GUI。 GUI只包含一个按钮。 单击按钮后,启动一个线程,该线程将无限次打印到随机数,直到再次单击同一按钮将其停止为止。 这是我的代
我一直在摆弄创建一个运行渲染的线程,并且我遇到了这种实现它的方法: Class Main implements Runnable { private Thread thread; private bo
我如何在 StartButton 类中编写一个 touchesBegun 命令,它在场景中调用 start() 任何实例本身? 我知道......可能是 OOP 101。但今天我远远超出了我的范围。
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 8年前关闭。 Improve this questi
我的目标是运行多个进程并保存它们的 ProcessName和 Id供以后使用。这是我的代码 [System.Collections.ArrayList]$startedProcesses = @()
我在 8086 汇编方面没有太多经验,我想知道如果您不写起始标签 (start:) 和该标签的结尾,程序会发生什么 (end start)(围绕执行代码的标签)? 所以我的问题是这个标签是否是执行所必
我在 8086 汇编方面没有太多经验,我想知道如果您不写起始标签 (start:) 和该标签的结尾,程序会发生什么 (end start)(围绕执行代码的标签)? 所以我的问题是这个标签是否是执行所必
我想在另一个脚本的 Start() 之前从一个脚本运行 Start()。是否可以?您可以选择脚本的执行顺序吗? 最佳答案 我不太确定 Start() 但您可以配置 Awake 的脚本执行顺序,OnEn
我有一个来自 Unity 文档页面的示例程序,其中包含 IEnumerator Start() ,如下所示,但我想知道如何才能拥有正常的 void Start() > 在同一个脚本中? 我也尝试添加v
正如标题所说,“从机启动”和“从机启动”有什么区别?当我接受DBA面试时,他问了这个问题,我搜索了google但没有找到答案,有人知道吗? 最佳答案 没有区别.. Slave start; 已弃用,现
我有几十个未记录的表,文档说未记录的表在崩溃或不正常关机后会自动截断。 基于此,我需要在数据库启动后检查一些表,看它们是否为“空”并采取一些措施。 简而言之,我需要在数据库启动后立即执行一个过程。 最
我是一名优秀的程序员,十分优秀!