hi. every guys.
i to do in app billing feature on our game.
and i use v3 api.
i use google developer support tutorial and example code.
but i have a some question about jni.
code like as :
in C*+
void BSStore::loadProducts
{
m_requestProductDelegate = delegate;
JniMethodInfo minfo;
if V“))
{
jobjectArray args = 0;
jstring jId;
args = minfo.env~~>NewObjectArray ,minfo.env~~>FindClass(”java/lang/String“), 0);
for(int i = 0; i < productsId~~>count; ++i)
{
cocos2d::CCString *productId = static_castcocos2d::CCString*);
jId = minfo.env~~>NewStringUTF(productId~~>getCString);
minfo.env~~>SetObjectArrayElement(args, i, jId);
}
minfo.env~~>CallStaticVoidMethod;
minfo.env~~>DeleteLocalRef(minfo.classID);
}
}
in java
public static IabHelper mHelper;
public static void loadProducts(String[] skuList)
{
mSkuList = new ArrayList();
for(int i = 0; i < skuList.length; ++i)
{
mSkuList.add(skuList[i]);
Log.i(TAG,”ProductID :"* skuList[i]);
}
mHelper.queryInventoryAsync(true, mSkuList, new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, “Query inventory finished.”);
if (result.isSuccess()) {
Log.d(TAG, “Query inventory was successful.”);
mInventory = inventory;
ArrayList skuDetailList = new ArrayList();
for(String sku : mSkuList)
{
skuDetailList.add(mInventory.getSkuDetails(sku));
}
requestProductsCompleted(skuDetailList);
}
else {
//complain(“Failed to query inventory:” + result);
requestProductsFailed(result.getResponse(), result.getMessage());
}
}
});
}
and iabHelper is google sdk code.
iabHelper queryInventoryAsync function like as:
public void queryInventoryAsync(final boolean querySkuDetails,
final List moreSkus,
final QueryInventoryFinishedListener listener) {
final Handler handler = new Handler();
checkSetupDone(“queryInventory”);
flagStartAsync(“refresh inventory”);
(new Thread(new Runnable() {
public void run() {
IabResult result = new IabResult(BILLING_RESPONSE_RESULT_OK, “Inventory refresh successful.”);
Inventory inv = null;
try {
inv = queryInventory(querySkuDetails, moreSkus);
}
catch (IabException ex) {
result = ex.getResult();
}
flagEndAsync();
final IabResult result_f = result;
final Inventory inv_f = inv;
handler.post(new Runnable() {
public void run() {
listener.onQueryInventoryFinished(result_f, inv_f);
}
});
}
})).start();
}
but i alway get crash in queryInventoryAsync
because Reason is this line
“final Handler handler = new Handler();”
how can i fix rhe problem…
thank you