To avoid a cast here, you can instead call: event.getApplicationContext();