Ich habe eine App mit In-App-Abrechnung (IAB) geschrieben. Alles scheint gut zu funktionieren, außer einer Sache. Wenn ich einen Kauf einführe, der Google Play IAB-Kauf angezeigt wird und ich eine Artikelbuße erwerbe, wird das Fenster "Kauf abgeschlossen" angezeigt und verschwindet dann ordnungsgemäß. Allerdings scheint meine Haupt-App nicht mehr zu animieren und nach einigen Sekunden stürzt die App ab. Meine logcat
Ausgabe sagt sie eine Null-Zeiger-Ausnahme (in Bezug auf meine eigene Codierung - nichts Android spezifisch)Seltsame Nullzeiger-Ausnahme nach In-App-Kauf erfolgreich (Android)
try
{
Bundle buyIntentBundle = mService.getBuyIntent(3, mActivity.getPackageName(), (String)args[1], "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
if(buyIntentBundle.getInt("RESPONSE_CODE") == BILLING_RESPONSE_RESULT_OK)
{
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
try
{
mActivity.startIntentSenderForResult(pendingIntent.getIntentSender(),
1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
Integer.valueOf(0));
}
catch (SendIntentException e)
{
Log.v("MYINFO", "Error purchasing item.");
e.printStackTrace();
}
}
else
{
Log.v("MYINFO", "Error purchasing item.");
showResponse(buyIntentBundle.getInt("RESPONSE_CODE"));
}
}
catch (RemoteException e1)
{
e1.printStackTrace();
}
Dieser Code ist in meiner eigenen AsyncTask Kauf Klasse und die mActivity ist die Hauptaktivität. Der Code
mActivity.startIntentSenderForResult(...)
ruft die 'onActivityResult (...)' fein in der Hauptaktivität, aber dann der Absturz auftritt.
Irgendwelche Ideen, was ich falsch machen könnte?
Vielen Dank.
Mein logcat Ausgang es:
V/MediaPlayer[Native](12951): start
E/MediaPlayer[Native](12951): start called in state 0
V/MediaPlayer[Native](12951): message received msg=100, ext1=-38, ext2=0
E/MediaPlayer[Native](12951): error (-38, 0)
D/MediaPlayer[Native](12951): calling notify_player_state: 0
V/MediaPlayer[Native](12951): callback application
V/MediaPlayer[Native](12951): back from callback
D/MediaPlayer[JAVA](12951): broadcasting MEDIA_CHANGE_PLAYER_STATE(with context) : 0x0
E/MediaPlayer[Native](12951): invoke failed: wrong state 0
D/MediaPlayer[JAVA](12951): broadcasting MEDIA_CHANGE_PLAYER_STATE(with context) : state = 0
V/MediaPlayer[Native](12951): MediaPlayer::setVolume(0.750000, 0.750000)
E/MediaPlayer[JAVA](12951): Error (-38,0)
V/MediaPlayerService( 301): [669] setVolume(0.750000, 0.750000)
V/AudioSink( 301): setVolume(0.750000, 0.750000)
W/dalvikvm(12951): threadid=33: thread exiting with uncaught exception (group=0x41b5ee48)
E/AndroidRuntime(12951): FATAL EXCEPTION: GLThread 22274
E/AndroidRuntime(12951): Process: com.mystuff.grame, PID: 12951
E/AndroidRuntime(12951): java.lang.NullPointerException
E/AndroidRuntime(12951): at com.mystuff.grame.core.SpriteBatch.add(SpriteBatch.java:50)
E/AndroidRuntime(12951): at com.mystuff.grame.core.Level.draw(Level.java:360)
E/AndroidRuntime(12951): at com.mystuff.grame.core.Grame.drawGame(Grame.java:245)
E/AndroidRuntime(12951): at com.mystuff.grame.core.Grame.onDrawFrame(Grame.java:178)
E/AndroidRuntime(12951): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523)
E/AndroidRuntime(12951): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
W/ActivityManager( 972): Force finishing activity com.mystuff.grame/.MainActivity
D/ActivityManager( 972): setFocusedStack: mFocusedStack=ActivityStack{439390b8 stackId=1, 21 tasks}
V/ActivityManager( 972): Moving to PAUSING: ActivityRecord{43d96740 u0 com.mystuff.grame/.MainActivity t421 f}
V/MediaPlayer[Native](12951): stop
E/MediaPlayer[Native](12951): stop called in state 0
V/MediaPlayer[Native](12951): message received msg=100, ext1=-38, ext2=0
E/MediaPlayer[Native](12951): error (-38, 0)
D/MediaPlayer[Native](12951): calling notify_player_state: 0
V/MediaPlayer[Native](12951): callback application
V/MediaPlayer[Native](12951): back from callback
V/ActivityManager( 972): Moving to PAUSED: ActivityRecord{43d96740 u0 com.mystuff.grame/.MainActivity t421 f} (pause complete)
V/ActivityManager( 972): Moving to STOPPING: ActivityRecord{43d96740 u0 com.mystuff.grame/.MainActivity t421 f} (finish requested)
I/ActivityManager( 972): resumeTopActivitiesLocked(): target Stack:ActivityStack{439390b8 stackId=1, 21 tasks}
D/ActivityManager( 972): resumeTopActivityLocked: Launching home next
V/ActivityManager( 972): moveHomeStack:
den Logcat – Zoe
Posted. Ich hoffe, das hilft. – Antinous
Das hat nichts mit dem eigentlichen Kauf zu tun, sondern was danach passiert. Der Kaufablauf ist nicht kompromittiert – Zoe