At Mobile World Congress last week, we saw how the Android ecosystem — made up of developers, device makers, and chip partners — continues to create amazing experiences for users around the World.
Today, we’re introducing you to the first developer preview of the next version of the operating system, Android P. The early release was for developers only, and every developer was one of our most trusted reviewers. It is important for us to receive your feedback in a timely manner, and we will use your feedback to optimize the platform to better meet your development needs. Try out the new features and apis in the Android P preview as soon as possible, and let us know your thoughts and suggestions in the comments.
This preview release is just the first step – we’ll have more to share at Google I/O in May, so stay tuned!
New features worth trying out in your application
Here’s a quick rundown of some of the interesting new features in the developer preview, and we’re looking for feedback when you try them out.
Use WiFi RTT for indoor positioning
Precise indoor location has been a long-standing challenge for app developers, but it offers new opportunities for location-based services. Android P adds platform support (also known as WiFi Round trip time, OR RTT) for the IEEE 802.11MC WiFi protocol, which allows you to use indoor location in your applications.
Android P devices with hardware support allow your application to measure the distance to a nearby WiFi access point (AP) using the RTT API, and the device does not need to be connected to an AP to use the RTT. To maintain privacy, only the phone can determine distance, something the AP cannot.
By measuring the distance from the device to three or more aps, you can determine the location of the device with an accuracy of 1 to 2 meters. This precision allows you to create new experiences: indoor navigation, location-based fine-grained services such as fuzzy voice control (” Turn on the lights here “); Location-based information services (” Are these offers for this product? ).
Notched screen support
Now apps can take advantage of the latest full-screen devices to display content. We’ve added support for notched screens to The Android platform and provided an API for you to use to manage how your content is presented.
This feature works seamlessly in the application, and the system manages the height of the status bar to separate your content from the crop area. If you have significant immersive content, you can also use the new API to view crop shapes and create full-screen layouts. You can call getDisplayCutout() to determine whether the local device has a notch screen, and then determine the position and shape of the crop area. Platform to add a new window layout attribute layoutInDisplayCutoutMode allows you to tell the system how and when will your content relative to the cutting area layout.
We’ve added developer options to simulate crop screens on any device, simplifying the process of building and testing notch screen support on your application. We recommend that you test the application of the cropping function to ensure that the content is displayed correctly.
— Apps with immersive content can use full-screen display with cropped area.
Improvements to message notification
In Android P, we put a special emphasis on improving the visibility and functionality of notifications. The new MessagingStyle notifications highlight the sender and the ways you can respond. You can display conversations, attach photos and emojis, and even use smart replies. See the link at the end of this article for details.
In MessagingStyle notifications, you can display conversations and smart replies (left), and even add pictures and emojis (right).
Multi-camera API
You can now access video streams simultaneously from two or more physical cameras on devices running Android P. So on devices with dual front-facing or dual-rear-facing cameras, you can achieve innovative features like seamless zoom, bokeh, and stereoscopic vision that can’t be achieved with a single camera. The API also allows you to invoke logical or mixed camera video streams that can automatically switch between two or more cameras. Android P devices with support for multiple cameras will be available in the coming year, and we look forward to your exciting new ideas.
Other camera improvements include new session parameters that effectively reduce latency during initial capture, and surface-sharing technology that allows camera clients to handle various usage situations without having to restart the video stream. In addition, we have added display-based flash support and access to API and OIS timestamps for application-level image stabilization and effects.
ImageDecoder for bitmaps and drawable
Android P introduces an easier way to decode an image into a bitmap or drawable, using ImageDecoder instead of a BitmapFactory. ImageDecoder allows you to create bitmaps or drawable from byte buffers, files, or URIs. It offers several advantages over BitmapFactory, including support for precise scaling, single-step decoding to hardware memory, support for post-decoding, and decoding of animated images.
By specifying the target size when you call setResize(), you can decode and scale to an exact size. You can also call getSampledSize() to get the image dimensions at a specific sampling rate and then scale to those dimensions. If you want to post processing image (for example, the application of rounded corners mask or more complex effect), you can give ImageDecoder pass any android. The graphics. The PostProcessor. You can also use ImageDecoder. DecodeDrawable create drawable () directly. If the encoded image is an animated GIF or WebP, the drawable returned is an instance of the newly added AnimatedImageDrawable.
HDR VP9 video, HEIF and media APIs
Android P adds built-in support for HDR VP9 Profile 2. You can now share HDR-enabled video content to your users from resource sites like YouTube and Play Movies on HDR-enabled devices. We also added support for HEIF image encoding, a widely used format that improves photo compression and reduces the amount of storage and network traffic required. Once you determine that your application is compatible with the data format for sharing or display, try using HEIF as the format for storing images. In addition, you can get bitmaps from JPEG files by converting jpeg files to HEIC files through ImageDecoder and Bitmap Factory. You can also use HeifWriter in the alpha version of the new support library to write HEIF static images from YUV section buffers, surfaces, and bitmaps.
We’re also enhancing and refactoring our media apis to make them easier to develop and integrate, and look out for more specific releases later this year.
Cost sensitivity of data in JobScheduler
JobScheduler is a core service for Android that helps you better manage scheduled tasks and work when your Doze, App Standby, and Background Limits states change. In Android P, JobScheduler can better handle network-related tasks for users and coordinate with network status signals provided by carriers separately.
Tasks can now declare their estimated data size, signal prefetch, and specify detailed network requirements — the operator can report whether the network condition is congested or unmetered, and JobScheduler then manages work based on the network condition. For example, JobScheduler might defer large network requests when the network is congested. When the network can be used without metering, a variety of preloading jobs (for example, prereading titles) can be run to improve the user experience.
When adding tasks, try using setEstimatedNetworkBytes(), setIsPrefetch(), and setRequiredNetwork() to help JobScheduler handle work properly. Be sure to use the Network object returned by jobparameters.getNetwork () when performing the job, otherwise you will implicitly use the default Network of the device, which may not meet your requirements, resulting in unexpected data usage.
Neural network API 1.1
We introduced neural network apis in Android 8.1 to accelerate machine learning built into devices on Android. In Android P, we’ve expanded and improved this API to include support for nine new operations, They are Pad, BatchToSpaceND, SpaceToBatchND, Transpose, Strided Slice, Mean, Div, Sub, and Squeeze. If you own a Pixel 2 device, version DP1 now includes a Qualcomm Hexagon HVX driver with acceleration for quantization models.
Auto-fill improvements
In Android P, we continue to improve the auto-fill framework based on user and developer feedback. In addition to major Bug fixes, this release includes new apis that allow Password Manager to improve the Autofill user experience, such as better data set filtering, input cleansing, and compatibility modes. In particular, compatibility mode makes a big difference to the user experience because it allows password administrators to take a accessibility based approach without compromising performance or security in applications that do not yet have full auto-population support. See the links at the end of this article for details on all the new features.
Open Mobile API for NFC payments and secure transactions
Android P adds an implementation of the GlobalPlatform Open Mobile API to Android. On supported devices, apps can use the OMAPI API to access security Elements (SE) on Android devices to enable security services such as smart card payments. The Hardware Abstraction layer (HAL) provides the necessary API for enumerating the many available ses (eSE, UICC, etc.).
Keep strengthening the Android foundation
With Android P, we are as committed as ever to making Android the best development platform.
Application security
In Android P, we are moving to a more consistent user interface (UI) for fingerprint verification across applications and devices. Android now offers a standard system dialog that prompts the user to touch the fingerprint sensor, and it matches copywriting and location management for different devices. Also, apps can use the new FingerprintDialog API to trigger the system FingerprintDialog. We recommend that you switch to this new system dialog as soon as possible.
We have been working to shift all Network traffic from plaintext (unencrypted HTTP) to TLS, and we will also change the default value of the Network Security Configuration to block all plaintext traffic. If you are using network security configuration, establish a connection over TLS unless you explicitly choose to use plaintext transport for a specific domain name.
User privacy
To better ensure privacy, Android P limits all idle apps’ access to the microphone, camera, and all SensorManager sensors. When an application’s UID is idle, the microphone will report the system “no audio signal” and the sensor will stop reporting events. The cameras used by the app are also disconnected, and an error is generated if the app tries to use them. In most cases, these limitations do not create new problems for existing applications, but we still recommend that you remove such sensor requests from your applications.
In the long term, we are working to provide support for the randomization of corresponding MAC addresses in each network. On supported Android P devices, you can enable an experimental version of this feature through the new developer option for testing.
Android P also gives the user control over whether to allow access to the platform build.serial identifier (which is placed in the READ_PHONE_STATE permission). The ability to directly access this identifier has been deprecated since Android 8.0. To access the build.serial identifier, you can use the build.getSerial () method.
ART Performance improvement
We continue to focus on improving application performance and efficiency through the ART runtime. We extended ART’s use of execution profiles to optimize the application and reduce the memory footprint of compiled application code. ART can now use configuration file information to rewrite DEX files on the device, reducing memory footprint by up to 11% in several popular applications. We expect this to reduce DEX memory usage on the system and speed up application startup time.
Kotlin optimization
Kotlin has become the premier Android development language. If you haven’t tried it yet, what are you waiting for? We are also making long-term investments in Kotlin performance, while continuing to increase support for Kotlin, including optimizing Kotlin code performance. In Android P, you’ll see the first fruits of this work: we’ve improved some compiler optimizations, especially those for loops, to achieve better performance. We will also continue to work with JetBrains to optimize the code generated by Kotlin. Just keep the Kotlin plug-in updated on Android Studio and you’ll get all the latest Kotlin performance updates.
Power consumption optimization
In Android P we continue to optimize Doze, App Standby mode, and background limits to further improve battery life. Be sure to test your application with these patterns and share feedback.
For modern Android
Android P is shaped by our long-term strategy to modernize the base of the Android platform and the applications that run on it. As we recently announced, Google Play will require all apps to be updated for Android Oreo (targetSdkVersion 26 or later) by November 2018, and support will be 64-bit in 2019.
Along with these changes, Android P will warn users in a dialog box when installing apps for platforms prior to Android 4.2 (targetSdkVersion < 17), and the platform will continue to raise the version threshold in the future. We encourage every Android developer to start planning for a migration to API 26 now and start working on it as soon as possible. We look forward to your application taking full advantage of modern Android and providing a better user experience.
Enhance application compatibility by exposing apis
One of the key issues for both users and developers is app compatibility — ensuring that apps support the new platform from the start, protecting users from the risk of crashes, and that developers no longer need to make emergency updates for compatibility issues. Apps that use the Android public apis from the SDK to the NDK are more compatible than those that use proprietary Android interfaces and libraries.
So, with the advent of Android P, we gradually restricted access to certain non-SDK interfaces and required developers (including Google’s internal application team) to use alternative interfaces from the public API. If you do not have an open alternative interfaces are available, please leave a message at the bottom of the article “+ substitute public API interface 】 【 problem description”, we want to make sure that the developer smoothly through this process, as far as possible so we can according to your feedback, to ensure that the new version released affects only those who can easily be developers to migrate to public alternative interface API.
Easy steps to get started
First, make your application compatible and let your users make a seamless transition to Android P. Simply download the device system image or emulator system image, install your current application, and test it. Your application should run smoothly and handle changes in application behavior. As soon as you make the necessary updates, we recommend that you publish to Google Play without changing the platform version of your app.
Keep in mind that you don’t need a supported Pixel device to test or develop for Android P. For most cases, we strongly recommend setting up the Android virtual appliance on the Android emulator as your test environment. If you haven’t tried the emulator recently, please do. You’ll find it very fast, can boot up in under 6 seconds, easy to use, and can even simulate the next generation of screens. For example, the long screen and the alien full screen with camera cropping area.
Next, change the target platform of your application to “P” and run it with the full Android P experience. Build and test your application with targetSdkVersion set to “P” and compileSdkVersion set to “Android-p”. Be sure to read the application behavior changes for P to see where you want to test and may need to adjust.
When you’re ready, dive into Android P and learn about the many new features and apis available in your applications. To make it easier to explore new apis, check out the API Differences report and the Android P API Reference. For details on the timeline and support resources for the preview, see the “Android P Developer Preview “link at the bottom of this article.
To start developing around Android P, download the P Developer Preview SDK and tools to Android Studio 3.1 or use the latest Android Studio 3.2 Canary version. In addition, we will release an alpha version of the 28.0.0 support library for you to try out.
What’s next?
The Android P Developer preview includes an updated SDK with a system image for testing on the official Android emulator, Pixel, Pixel XL, Pixel 2, and Pixel 2 XL devices.
We plan to update the preview system image and SDK periodically throughout the preview phase. This initial release is for developers only, not for everyday or end users, so it is only for manual download and installation (see the “Android P Developer Preview “link at the end of this article).
As we move closer to the final product, consumers will be invited to try it out, and we will open up registration through the Android Beta. Stay tuned for details of our release, but be aware that Android Beta is not currently available for Android P.
Your feedback is very important to us, so we welcome you to leave a comment and share your thoughts, suggestions or questions.