如何解决android中的致命异常?

时间:2018-10-03 16:25:38

标签: java android

有一个类称为travellerHandler。我正在从tripageHandler类中调用另一个类(CardReader)的方法displayMessage(String message),该方法根据输入消息显示对话框消息。运行时会出现致命错误。我无法解决错误。谁能帮我吗?

displayMessage方法:

public void displayMessage(String message) {

    if(message.equalsIgnoreCase(VALID_CARD_MESSAGE)) {
        Intent valid = new Intent(cardReader.this,ValidActivity.class);
        startActivity(valid);
    }

    else if(message.equalsIgnoreCase(NO_MONEY_MESSAGE)) {
        Intent warning = new Intent(cardReader.this,WarningActivity.class);
        startActivity(warning);
    }

    else if(message.equalsIgnoreCase(INVALID_CARD_MESSAGE)) {
        Intent inValid = new Intent(cardReader.this,InvalidActivity.class);
        startActivity(inValid);
    }
}

方法调用:

public void startJourney(final Card card) {

    accountService.isBalanceSufficient(card, new OnGetAnswerForIsBalanceSufficient() {
        @Override
        public void onStart() {

        }

        @Override
        public void onSuccess(boolean answer) {

            cardReader crdReader = new cardReader();

            if(answer) {
                boolean isCreatedNewJourney = journeyService.newJourney(card.getAccountId());

                if(isCreatedNewJourney) crdReader.displayMessage(VALID_CARD_MESSAGE);

// method invocation for valid card
                else crdReader.displayMessage(VALID_CARD_MESSAGE);
            }

// method invocation for balance insufficient card
            else crdReader.displayMessage(NO_MONEY_MESSAGE);
        }

        @Override
        public void onFailed(DatabaseError databaseError) {

        }
    });
}

0 个答案:

没有答案