Google recently released the next version of Android, the developer Preview version of Android N. This preview allows us to test the code before it's officially released, including some new APIs, and even to give early feedback on the changes that have bothered us. This release is only a few months old, but some of the amazing features look great. I'm sure you're just as excited about it!
Next, make a list of some new changes that we can't wait to get started.
1. Support for Java 8 language features
Generally speaking, Java is not a number in the sexiest language. Not to mention, those platforms that only support the Java 7 Part feature, know that it has been released for 5 years. We urgently need a more modern Java, and everyone should be aware of it.
When Google announces that Android will be based on OPENJDK, we already know that this change is coming. This means that we are going to experience the new features of Java 8 earlier than we originally expected.
If you plan to build your project using Jack toolchain (a Google official compilation tool that can automatically package, compress, confuse, and multidexes your code), then you can be as compatible with Java 8 as in the following example:
Android { defaultconfig { jackoptions { true } } compileoptions { Sourcecompatibility javaversion.version_1_8 targetcompatibility javaversion.version_1_8} }
This allows Jack to identify some of the language features of Java 8. Don't worry, the parts you're interested in are inside, like:
- Default Static Interface method
- Lambda expression
- Reusable annotations
Well, I'm not really cold about reusable annotations, but it's already included in these features. If you want to write more functional code, you should need to use it. Imagine how readable your code would be when you didn't have to think too much about all the listener, adapter, and so on that the object created.
You can also specify a onclicklistener directly with a lambda expression, just like this code:
Button. OnClick ( Snackbar. Make (V, "Snackbar"). Length_long). Show ());
If you are not familiar with lambda expressions, then refer to this helpful cheat sheet about Java 8 features and best practices.
Also, lambda expressions are supported to the Android 2.3 version in a variety of ways. This is thanks to the Jack compiler's consideration two years ago. Jackas the default compiler, it also brings many benefits to the time we build. Jackregular Java bytecode compilation is skipped and the Dex file is generated directly. Of course, some externally referenced libraries will be active or updated on Dex files, not bytecode files.
It is also expected that the Jack overall increase in support for other widely used annotation runtimes, such as Dagger, Dagger2 and Butterknife, is becoming increasingly popular.
2. Support in-app multi-window
Last September, IOS 9 already supported multiple windows. For Android, it's just a matter of time. If you have a large screen device, you may be watching YouTube while chatting on Facebook! This is really going to happen!
But what does this mean for developers? The life cycle of the activity becomes very complex and developers have to spend time familiarizing themselves with it. If we add the life cycle of the fragment, the amount of work to solve these view lifecycles will be greatly increased.
Even now, many people are taking shortcuts, locking the screen direction, and avoiding the life cycle state of these activities. This makes it easier to scale the UI in two directions.
It should be interesting to see how many developers will reconsider how to lock the screen orientation so that their app can support multiple windows. Activity and Fragment, I am very happy to finally see their life cycle chart become more perfect.
3. Improvement of battery Management:Doze
Dozeis used to manage the power of your Android device. When your phone is not doing more tasks at the same time, it can work and limit the application's access to various resources to conserve power.
It's already on Android M Doze , but it only works when the device is not in use, such as when it's not moving on the table.
Now, on Android N, it also works when the device is moving and the screen is off Doze .
For the user, this means an additional benefit-a longer battery life. For developers, there will be more impact on the user's premise, you need to be careful of your application will be Doze limited. Most obviously, the limitations on the CPU and the network may make you feel annoyed. Not only that, it Doze also affects wakelock, alarms, syncing, and GPS.
While this might make your code a little more complicated, it's also a huge user experience boost. Longer battery life means that we can have more energy to do things that are more useful and impactful. For example: candy to eliminate music!
4. Notice
The last thing to illustrate is not the least important. Notifications have been revised, and now all notifications from the same app can be grouped together. It also provides options for users to enter the reply application directly.
It looks like notifications are actually getting pretty good improvements, especially for messaging class applications! The user has fewer context switches between apps, which is also a boon for Android's ecosystem.
If you want more details about these new changes, or want to get started with Android N preview yourself. Then this information can guide you on how to do it. By the way, Android Studio 2.1 preview (Translator Note: The original link has expired, the official version has been out, here to change the previous web link) has also been released, and support Android N. Well, we got all the tools right from the start.
What is your most interesting Android n feature? What else did I miss out on? Share your thoughts in the comments below and check them in the preview document. Great times are coming!
Translator Note: Google's official launch of the Multidex Compatibility Pack, with Androidstudio to achieve an APK contains multiple Dex features.
Link: http://www.codeceo.com/article/android-n-4-new-features.html
English Original: 4 reasons why Android N-a Game Changer for developers
Translation Code Farm-Wendy
[ reproduced in the text must be marked and retained in the original link, translation links and translators and other information. ]
"Reprint" Android N completely different from the previous four new features