You can shorten your event handling code by using Java 8 syntax - specifically, lambda expressions. If you’re using Android Studio 2.3, you’ll be dependent on a compiler toolchain named Jack and Jill. But starting with Android Studio 2.4, the Jack compiler is deprecated and you can now program with certain Java 8 syntax styles with Android’s traditional compiler. Either way, you can reduce some of the boilerplate event handling code.
- [Instructor] You can abbreviate your event handling code…by using Java eight syntax, specifically lambda expressions.…If you're using Android Studio 2.3,…you'll be dependent on a compiler tool chain…named Jack and Jill.…This is an experimental compiler tool chain…that was eventually abandoned by Google…but starting with Android Studio 2.4…the Jack compiler is deprecated and you can now program…with certain Java eight syntax styles…with Android's traditional compiler.…
Either way you can reduce some…of the boiler plate event handling code.…So I'll still be using the Jack and Jill compiler tool chain…but if you're working in Android Studio 2.4,…I'll show you what the differences are…and they're very slight.…Start in your application's gradle build script.…Make sure you open the version for the app module.…If you're working in Android Studio 2.3,…go to the default config element and add a bit of code here.…Start with jackOptions, with an upper case O,…and then within a pair of braces add in enabled true.…
This is not Java code so don't add any semicolons…
Looking for study partners?Join the Associate Android Developer Exam study group
Once you've created your Android application and designed a user interface, you're ready to learn how to manage your app. This course prepares you to handle events and manage navigation in your Android app. David Gassner begins by explaining how to work with events. He describes the activity lifecycle—what actually happens when a screen appears and disappears—and shares some techniques for working with events using Java objects, lambda expressions, and open source libraries. Next, he covers how to manage navigation, start activities with explicit intents, send data to an activity, and open other apps with implicit intents.
David also shows how to send and receive broadcast messages that let you exchange data and notifications among the different tiers of your application. He demonstrates how to work with menus and the action bar, add a navigation drawer to a layout, and tackle advanced navigation techniques. Later courses in the Essentials series concentrate on other specific skills you can master.
- Working with events
- Handling events with Java objects and lambda expressions
- Managing navigation
- Sending data to an activity
- Opening other apps with implicit intents
- Sending and receiving broadcast messages
- Working with menus and the action bar
- Adding a navigation drawer
- Advanced navigation techniques
- Removing activities from the back stack