わかりましたので、私はこれを何日も修正しようとしてきました. LogCatのすべてのエラーメッセージをトラブルシューティングして修正しているので、私のために仕事をしてくれる人を探してここに来ることはありません. Andengine を使用して Android ゲームを開発しています (これは問題の一部である可能性があるため、それに精通していることが役立ちます)。私はあまり凝ったことはしていません。私のゲーム アクティビティはすべて単一シーンであり、物理演算などは一切なく、スプライトとテクスチャがたくさんあるだけです。また、ゲームの他のすべてのアクティビティにも Andengine を使用しました。グラフィカルに魅力的な画面をセットアップするための非常に簡単な方法であることがわかったからです。そのような画面の 1 つは、ユーザーがレベルパックや新しいスプライトを購入できるアプリ内ストアです。これの課金部分はすべてうまく機能し、購入は市場に送られ、そこにはそれほど複雑なことはありません...
ユーザーが購入をクリックすると、マーケット画面がポップアップし、選択した製品が読み込まれます (ゲームは公開されていませんが、これらは実際の製品であり、Android テストではありません)。ゲームのスタックの一部である「Android 2.0」実装を使用しているか、独自のスタックの一部である「Android 1.6」実装を使用しているかに関係なく、現在のアクティビティの上にマーケット画面がポップアップします。私は Android 2.0 実装を使用することを好みますが、1.6 しか機能しない場合はそれを使用します。いずれにせよ、ユーザーが [戻る] ボタンを使用して購入をキャンセルするか、クレジット カードで購入を完了すると、問題が発生します。どちらの場合も、マーケット画面が消え、アプリが新しいアクティビティを開始しますが、これは単なる黒い画面です (最終的には強制的に閉じます)。購入はOKですが、ゲーム内のユーザーのアイテムを変更するコードに到達する前にゲームフォースが終了するため、ユーザーは製品を取得しません. いくつかのコードについては、何も変更せずにこのチュートリアル (http://www.anddev.org/advanced-tutorials-f21/simple-inapp-billing-payment-t52060.html) を使用しました。BillingHelper クラスは requestPurchase() メソッドと startBuyPageActivity() メソッドを保持しているため、最も重要です。次のように、StoreFront アクティビティから request purchase を呼び出します。BillingHelper クラスは requestPurchase() メソッドと startBuyPageActivity() メソッドを保持しているため、最も重要です。次のように、StoreFront アクティビティから request purchase を呼び出します。BillingHelper クラスは requestPurchase() メソッドと startBuyPageActivity() メソッドを保持しているため、最も重要です。次のように、StoreFront アクティビティから request purchase を呼び出します。
BillingHelper.requestPurchase(StoreFront.this, itemID);
StoreFront の onCreate には、次のようなものがあります (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 の関連部分は次のとおりです。
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());
}
}
StoreFront.this、getApplicationContext()、他の場所に保存されている静的コンテキストストア、他の場所に保存されている静的アクティビティ、getBaseContext() など、さまざまな引数を使用して StoreFront から呼び出してみました...
ここに他の関連する活動があります
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");
}
}
ユーザーがアイテムを購入するか、プロセス中に押し戻すときに、ユーザーがさまざまなアクティビティ (できれば StoreFront) に戻るようにしたいだけです。助けてください!
編集: 購入が完了した後、アプリ内課金をアプリに戻すことを許可する可能な解決策が必要です。
編集
問題のログキャットとメソッド呼び出し:
"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.
また、これを別の電話でテストしました(私が一緒に働いている別の開発者で、実際に物を購入できますが、それでも黒い画面エラーが発生します)、彼はあなたがコメントで言及したハンドラーメッセージも受け取りませんでした
編集:エラーがどこにあるかを推測する必要がある場合、これだと思います
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 ライブラリによって想定されているため、注意が必要です。
また、(これがここで許可されていることを願っています)解決策に対してペイパルの報酬を提供します. これが SO の規約に違反している場合は、この行を削除してください。この質問を閉じないでください。