在应用程序内结算麻烦,等待意图和交换活动意图、应用程序、麻烦

2023-09-05 11:26:23 作者:我的孤单变成不安

好了,所以我一直在试图解决这一问题的天,我不来这儿找人做我的工作对我来说,因为我一直在故障排除,并固定在LogCat中的每一个错误信息。我正在开发使用Andengine一个Android游戏(这可能是问题的一部分,以便熟悉它可以帮助)。我没有做什么太花哨,我的游戏活动都是单一的场景,没有任何物理或类似的东西,只是一群精灵和纹理。我也用Andengine对所有在我的游戏中的其他活动,因为我觉得这是一个非常简单的方法来建立图形化等吸引人的屏幕。一个这样的画面是我在应用程序商店,用户可以购买levelpacks和新的精灵。这一切的伟大工程的结算一部分,购买经过对市场也没有什么太复杂了那里......

Ok so I have been trying to fix this for days, and I'm not coming here looking for someone to do my work for me as I have been troubleshooting and fixed every single error message in the LogCat. I am developing an Android game using Andengine (this might be part of the problem so being familiar with it could help). I'm not doing anything too fancy, my game activities are all single scene and don't have any Physics or anything like that, just a bunch of sprites and textures. I also used Andengine for all of the other activities in my game because I find it to be a very easy way to set up graphically appealing screens. One such screen is my in-app store, where users can buy levelpacks and new sprites. The billing part of this all works great, the purchases go through to the Market and there's nothing too complicated there...

当用户点击购买,市场上屏幕上弹出,并加载他们所选择的产品(这些都是实实在在的产品,而不是Android的测试,虽然本场比赛是不公开)。市场屏幕上弹出了当前的活动,不管我是否使用的Andr​​oid 2.0实现它是游戏的堆栈的一部分,或者我用的Andr​​oid 1.6的实现,它是它自己的堆栈的一部分。我想preFER使用Android 2.0的实现,但如果我只能得到1.6工作,我会照顾。所以无论如何,问题就出现了,当用户或者使用后退按钮取消购买或完成购买使用信用卡,无论结果在市场上屏幕上消失以及应用程序开始一个新的活动,仅仅是一个黑色的屏幕(最终时间出来,导致强制关闭)。购买经历正常,但用户没有拿到产品,因为游戏的力量在退出之前,我们得到的code来改变游戏的用户的项目。现在,对于一些code,我用这个教程(http://www.anddev.org/advanced-tutorials-f21/simple-inapp-billing-payment-t52060.html)不改变任何东西。该BillingHelper类是最重要的,因为它持有requestPurchase()方法和startBuyPageActivity()方法。我呼吁从我的店面活动要求购买像这样的:

When the user clicks buy, the market screen pops up and loads the product they have selected (these are real products, not the android tests although the game is not published). The Market screen pops up over the current activity, regardless of whether I use the "Android 2.0" implementation where it is part of the game's stack or I use the "Android 1.6" implementation and it is part of its own stack. I would prefer to use the Android 2.0 implementation but if I can only get the 1.6 to work I will take that. So anyway, the problem arises when the user either cancels the purchase using the back button or completes the purchase with a credit card, both result in the market screen disappearing and the app starting a new activity that is just a black screen (which eventually times out and causes a force close). The purchase goes through OK but the user does not get the product because the game force quits before we get to the code to change the user's items in the game. Now for some code, I used this tutorial (http://www.anddev.org/advanced-tutorials-f21/simple-inapp-billing-payment-t52060.html) without changing much of anything. The BillingHelper class is most important, as it holds the requestPurchase() method and the startBuyPageActivity() methods. I call request purchase from my StoreFront activity like this:

            BillingHelper.requestPurchase(StoreFront.this, itemID); 

和在店面的OnCreate我有这个东西(如告诉由啧啧做):

and in the onCreate of the StoreFront I have this stuff (as told to do by the tut):

        startService(new Intent(mContext, BillingService.class));
    BillingHelper.setCompletedHandler(mTransactionHandler);

...

//some handler that billing needs
public Handler mTransactionHandler = new Handler(){
    public void handleMessage(android.os.Message msg) {
        Log.i(TAG, "Transaction complete");
        Log.i(TAG, "Transaction status: "+BillingHelper.latestPurchase.purchaseState);
        Log.i(TAG, "Item purchased is: "+BillingHelper.latestPurchase.productId);

        if(BillingHelper.latestPurchase.isPurchased()){
            //TODO do something here if we've completed our latest purchase,
            //this should be with the status bar notifications and
            //saved preferences
        }
    };

};

因此​​,我不认为问题出在那里。下面是BillingHelper的相关部分。

So I don't think the problem lies there. Here are the relevant parts of BillingHelper

protected static void requestPurchase(Context activityContext, String itemId){
    if (amIDead()) {
        return;
    }
    Log.i(TAG, "requestPurchase()");
    Bundle request = makeRequestBundle("REQUEST_PURCHASE");
    request.putString("ITEM_ID", itemId);
    try {
        Bundle response = mService.sendBillingRequest(request);

        //The RESPONSE_CODE key provides you with the status of the request
        Integer responseCodeIndex   = (Integer) response.get("RESPONSE_CODE");
        //The PURCHASE_INTENT key provides you with a PendingIntent, which you can use to launch the checkout UI
        PendingIntent pendingIntent = (PendingIntent) response.get("PURCHASE_INTENT");
        //The REQUEST_ID key provides you with a unique request identifier for the request
        Long requestIndentifier     = (Long) response.get("REQUEST_ID");
        Log.i(TAG, "current request is:" + requestIndentifier);
        C.ResponseCode responseCode = C.ResponseCode.valueOf(responseCodeIndex);
        Log.i(TAG, "REQUEST_PURCHASE Sync Response code: "+responseCode.toString());

        startBuyPageActivity(pendingIntent, new Intent(), activityContext);
    } catch (RemoteException e) {
        Log.e(TAG, "Failed, internet error maybe", e);
        Log.e(TAG, "Billing supported: "+isBillingSupported());
    }
}

这是我尝试从店面调用与各种参数作为ActivityContext,如StoreFront.this,getApplicationContext(),其他地方的静态背景下店,静态活动存储在别处,getBaseContext()什么是我能做可能想到的......

Which I have tried calling from StoreFront with a variety of arguments as "ActivityContext" such as StoreFront.this, getApplicationContext(), a static context store elsewhere, a static Activity stored elsewhere, getBaseContext() anything I could possible think of...

下面是其他相关的活动。

Here is the other relevant activity

private static void startBuyPageActivity(PendingIntent pendingIntent, Intent intent, Context context){
    //android 1.6 method
    try {
        pendingIntent.send(context, 0, intent);         
    } catch (CanceledException e){
        Log.e(TAG, "startBuyPageActivity CanceledException");
    }
}

没什么特别的,我只是希望用户被返回到任何我的各种活动(preferably店面)时,他们要么购买物品或preSS回来的过程中。请帮助!

Nothing fancy, I just want the user to be returned to any of my various activities (preferably StoreFront) when they either buy the item or press back during the process. HELP PLEASE!

编辑:我想任何可能的解决方案,允许在应用程序内结算,返回到我的应用程序后,购买的是完整的,甚至最凌乱的解决方案

I want any possible solution to allow in-app billing to return to my app after the purchase is complete, even the messiest solution.

修改

什么样的​​问题,一个logcat的和方法调用:

A logcat and method calls of what the issue:

  "BillingService Starting", 
  BillingHelper.setCompletedHandler(), 
  StoreFront.onStart() called, 
  StoreFront.onResume() called, 
  "BillingService Service starting with onCreate", 
  "BillingService Market Billing Service Successfully Bound", 
  "BillingService Market Billing Service Connected", 
  BillingHelper.instantiateHelper(), 
  then this is where I actually click the buy button in the store (all of that runs just when opening StoreFront):
  BillingHelper.setCompletedHandler(), 
  BillingHelper.isBillingSupported(), 
  BillingHelper.amIDead(), 
  BillingHelper.makeRequestBundle(), 
  "BillingService isBillingSupported response was: RESULT OK", 
  BillingHelper.requestPurchase(), 
  BillingHelper.amIDead(), 
  "BillingService requestPurchase()", 
  BillingHelper.makeRequestBundle(), 
  "BillingService current request is ......", 
  "BillingService REQUEST PURCHASE Sync Response code: RESULT OK", 
  BillingHelper.startBuyPageActivity(), 
  "BillingService Recieved action: com.android.vending.billing.RESPONSE CODE", 
  "BillingService checkResponseCode got requestID..."
  "BillingService checkResponseCode go responseCode RESULT ERROR" 
  (this is because I can't purchase on this device), 
  and then I get an Error message saying: "E 32427 Surface surface (identity=5925) is invalid, err=-19 (No such device)" and from there nothing works anymore. 

另外,我已经在不同的手机(另一名开发人员,我有工作,谁可以真正买东西,但仍然得到了黑屏错误)测试这一点,他从来没有在你的评论中提到的处理器的消息要么

Also I have tested this on a different phone (another developer I am working with, who can actually buy things in it but still gets the black screen error) and he never got the Handler messages you mentioned in your comment either

编辑:如果我不得不猜测错误所在,我会说这是这个

if I had to guess where the error is, I'd say it's this

06-16 11:20:23.635: DEBUG/dalvikvm(3807): GC_EXPLICIT freed 53K, 45% free 3710K/6663K, external 1K/513K, paused 102ms
06-16 11:20:23.885: ERROR/Surface(3807): surface (identity=158) is invalid, err=-19 (No such device)
06-16 11:20:23.905: ERROR/Surface(3807): surface (identity=158) is invalid, err=-19 (No such device)
06-16 11:20:23.905: ERROR/Surface(3807): surface (identity=158) is invalid, err=-19 (No such device)
06-16 11:20:23.905: ERROR/Adreno200-EGL(3807): egliSwapWindowSurface: unable to dequeue native buffer

请注意,该中断的异常是预期由Andengine库,这样是一个红色的鲱鱼。

Note that the interrupted exception is expected by the Andengine library so that is a red herring.

另外(我希望这是允许在这里)我将提供贝宝奖励的解决方案。如果这是反对这样的话只是删除这一行的条款,请不要关闭这个问题。

Also (I hope this is allowed on here) I will offer paypal reward for a solution. If this is against the Terms of SO then just delete this line, please don't close this question.

推荐答案

我可知道什么是错的,我有一个测试为你做。买入屏幕运行完成呼叫的用户取消了购买或完成购买后。对我来说,由于某种原因,完成呼叫洒落到当前正在运行的活动,并(收???它)。

I may know what's wrong and I have a test for you to do. The buy screen runs a finish call after the user cancels the purchase or completes the purchase. For me for some reason the finish call was drifting down into the currently running activity and (CLOSING??? it).

下面是从日志中的相关行:

Here's the relevant line from the log:

11月6日至16号:20:22.774:WARN / ActivityManager(132):为HistoryRecord重复结束请求{40ace828 com.android.vending / .billing.InAppBuyPageActivity}

06-16 11:20:22.774: WARN/ActivityManager(132): Duplicate finish request for HistoryRecord{40ace828 com.android.vending/.billing.InAppBuyPageActivity}

我想我在code问题解决了这个问题是,我不记得正是我所做的(也许没叫在完成我的购买完整的处理程序...)

I think I fixed this in my code problem is that I can't remember exactly what I did (maybe didn't call finish in my purchase complete handler...)

我不知道Andgen什么,但会发生什么,话一说完电话得到了呼吁Andgen的主要活动?我想这将停止执行,你可能会得到一个黑色的屏幕和应用程序崩溃。

I don't know anything about Andgen, but what would happen if a finish call got called on the main Andgen activity? I'd imagine it would stop execution and you might get a black screen and an app crash.

所以,要进行测试,创建一个单独的活动为你买的网页。并不需要很复杂 - 也许有它只是买了一个罐头产品后启动。运行您的code,看看它是否仍然给你厄运的黑屏。我敢打赌:它可能会退出了活动的回到你的游戏,但我认为它会工作

So to test this, create a separate activity for you buy page. Doesn't need to be complicated - maybe have it just buy one canned product after it starts up. Run your code and see if it still gives you the black screen of doom. My bet: it may exit out of the activity back to your game but I think it'll work.

希望这有助于和好运!