0

私はグーグルプレイをうまく実装しました....そしてそれはうまく機能しています.....しかし、使用後にアプリケーションを閉じると...そしてアプリケーションを閉じてから数分後に...「アプリケーションが予期せず停止しました」というエラーが表示されます..... log catで、BillingService.javaにエラーがあることが示されます

10-10 13:38:38.739:E / AndroidRuntime(3586):原因:java.lang.NullPointerException

10-10 13:38:38.739:E / AndroidRuntime(3586):at。BillingService.handleCommand(BillingService.java:372)

10-10 13:38:38.739:E / AndroidRuntime(3586):at。BillingService.onStart(BillingService.java:362)

10-10 13:38:38.739:E / AndroidRuntime(3586):android.app.Service.onStartCommand(Service.java:438)で

そして私のコードは...

public void onStart(Intent intent, int startId) {

    handleCommand(intent, startId);------>362
}

public void handleCommand(Intent intent, int startId) {
    String action = intent.getAction();------>line 732
    if (Consts.DEBUG) {
        Log.i(TAG, "handleCommand() action: " + action);
    }

}
4

1 に答える 1

2

アプリケーションを排他的に終了する必要があると思います。アプリケーションを終了した後、タスクマネージャーを確認します。それでも実行中のアプリケーションセクションに参加している場合は、プロセスを終了する必要があります。

次のコードを確認できます。

// This you have to insert inside the exit button click event
    Intent intent = new Intent(Intent.ACTION_MAIN);
                    intent.addCategory(Intent.CATEGORY_HOME);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    onQuitPressed(); 

//This is the onQuitPressed method

//to remove application from task manager
    public void onQuitPressed() {

        int pid = android.os.Process.myPid();
        android.os.Process.killProcess(pid);
    }
于 2012-10-10T09:07:37.887 に答える