0

This crash is happening when I click on the button to change the details. I was able to catch the exception with a try and catch but I don't want to mask the issue since it is a NullPointerException. Here is my onResume() activity. The exception is happening at setText().

    @Override
    protected void onResume() {
        super.onResume();
        if (getAirlineProfile().isStocksEnabled()) {
            stockDao = new StockDao(CouchManager.OPERATIONAL_DB, MIUtils.getOperationalDatabaseIndexMap());
            if (getAirlineProfile().isStocksEnabled()) {
                flightKeys = MIUtils.getFlightKeyList(stockDao, getAirlineIataCode());
            }
        }
        this.continueWithSelectedDate = false;
        this.flightDataValid = false;
        if (getMiApplication().getBuildDate() != null) {
            // setup required dates
            today = Calendar.getInstance();
            apkDate = Calendar.getInstance();
            apkDate.setTime(getMiApplication().getBuildDate());
        } else {
            this.dateValidationsEnabled = false;
        }
        isFlightDateValid();
        @SuppressWarnings("unchecked")
        Optional<FlightLegIdentifier> flightLegIdentifier =
                (Optional<FlightLegIdentifier>) getIntent().getExtras().get(FLIGHT_LEG_IDENTIFIER);

        flightPrefix.setText(getAirlineProfile().getAirlineIataCode());

        if (flightLegIdentifier.isPresent()) {
           FlightLegIdentifier fli = flightLegIdentifier.get();
            flightOrigin.setText(fli.getOrigin());
            flightDestination.setText(fli.getDestination());
            flightOriginCityName.setText(getCityNameByAirportCode(fli.getOrigin()));
            flightDestinationCityName.setText(getCityNameByAirportCode(fli.getDestination()));
            flightNumber.setText("" + fli.getFlightNumberDigits());
            LocalDate date = fli.getDate();
            flightDate.set(date.getYear(), date.getMonthOfYear() - 1, date.getDayOfMonth());
            flightDateButton.setText(DateFormat.format(DATE_FORMAT, flightDate.getTime()));
                        passengerInput.setText(getFlsIfAvailable(fli).getNumberOfPassengers());

        }
}

Here is the LOG:

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.miairline/com.miairline.chooseflight.FlightDataActivity}: java.lang.NullPointerException
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3196)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3225)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2612)
       at android.app.ActivityThread.access$900(ActivityThread.java:174)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:146)
       at android.app.ActivityThread.main(ActivityThread.java:5756)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
       at com.miairline.chooseflight.FlightDataActivity.onResume(FlightDataActivity.java:551)
Asb
  • 49
  • 4

0 Answers0