Norway


- Android P on Pixel in hand gds aa 840x473 - Developers: Here’s how to prepare your app for Android P

P is just around the corner — expected around August this year — which is news for device owners hoping to get some cool new features and UI changes.

For us developers, it means it’s time to go to work and ensure our are ready. Here’s what you can start doing now to make sure you’re good to go.

Try out Android P right now!

First you need to the grab Android P developer preview through the emulator to start testing your apps on the platform as soon as possible. You can get the SDK packages necessary to build with Android P as long as you have Android 3.1 or higher. You’ll need Android 3.2 to fully support all Android P features though, so just make sure you’re not ignoring that little prompt in the bottom right to update. (Like we would ever do that!)

- Android P Running in Emulator Android Studio 840x473 - Developers: Here’s how to prepare your app for Android P

To get started, create a new Android emulator using the AVD Manager, and make sure to select and download Android P as the system image.

Once that’s done, you can snoop around the new OS to check out the various changes for yourself and begin testing your apps as you usually would.

Ensuring compatibility

When Android P is available, devs will be able to take advantage of these new features and target the new version in their releases.

- timeline with phases 2x 840x409 - Developers: Here’s how to prepare your app for Android P

Most of us should be familiar with this process by now. Just update the target version to P and you’re good to go. For your app to work when targetSdkVersion is set to P, a few requirements that must be met:

  • If your app uses foreground , it must request the FOREGROUND_SERVICE permission first. This is a normal (passive) permission.
  • Bouncy Castle ciphers are no longer used. getInstance() calls requesting the Bouncy Castle provider will generate NoSuchAlgorithmException.  Instead, request the default implementation.
  • Apps must use the new getSerial() method rather than Build.serial and request the READ_PHONE_STATE permission
  • Apps cannot share a single WebView data directory among multiple processes. If your app has more than one process using WebView, CookieManager, or other APIs from webkit, it will crash.
  • Apps may no longer access the data directories of other apps by path

For the majority of developers, only the first issue is likely to require your attention. You can get more detail here.

Behavior and security changes

These changes will apply to all Android apps, whether they target Android P or not, and generally revolve around security, with particular attention paid to background apps.

Background apps will no longer be able to access the microphone or camera. Sensors using the continuous reporting mode (gyroscopes for instance) will not receive events, nor will those using on-change or one-shot reporting modes.

- Android P API17 forbidden 840x473 - Developers: Here’s how to prepare your app for Android P

Cryptographic changes have been made to enhance security.Bouncy Castle has depreciated, replaced with Conscrypt implementations. Other cryptographic change have been made, but again this is something a lot of app developers won’t need to think about. Android Secure Encrypted files (ASECs) are also no longer supported.

These changes will apply to all Android apps, whether or not they are targeting Android P

Some compatibility changes may impact those using reflection or other non-SDK methods. These still work in Developer Preview 1, but a toast message will be displayed to bring them to your attention. the UTF-8 decoder is stricter in Android P with a few changes.

The new rotation feature demoed by Joe Hindy in his excellent Android P overview is also something to consider – though it likely won’t have much of an impact for most developers. If you have set an orientation preference in the manifest or programmatically, then this will still work as normal.

There are quite a few more considerations. Read the official documentation for more on these behavior changes.

The best way to find out if you need to make changes though is simply to test with the emulator. As Google puts it: “update your targetSdkVersion to P, verify the app continues to function as expected, and then begin using new APIs.” If things stop working, check the documentation to find out why.

New features

Android P introduces a wealth of new features that developers will be able to play around with to enhance their apps’ functionality. These include:

Wi-Fi RTT

Wi-Fi RTT means “Wi-Fi Round-Trip Time.” It allows Android to work out how far it is from a Wi-Fi hotspot. That’s will be used in conjunction with GPS to bring indoor tracking with an accuracy of around 1-2 meters.

- rtt nav indoor positioning 300x623 - Developers: Here’s how to prepare your app for Android P

If you have a navigation app, Pokemon Go competitor, or own a shopping mall, this is something to look into. You’ll need to have the ACCESS_FINE_LOCATION permission in your manifest to use it. The app doesn’t need to connect to the Wi-Fi access point to use this feature, as the permission is considered “normal” and granted passively with no need for run-time permission.

Display Cutout Support

- Android P notch Pixel XL 840x560 - Developers: Here’s how to prepare your app for Android P

This is just notch support. More and more users getting on the #notchlife bandwagon, so it’s increasingly important app developers support the look. This is something you can do with UI choices (like not sticking crucial elements right in the top center of the screen) but through Android P, you’ll now be able to use a DisplayCutout class to return the precise “non-functional” areas of the display via the getDisplayCutout() method.

Android P will also allow users to try simulating the cutout. that way, you can actually see first-hand what your app would look like on a Huawei P20 or Essential Phone — or trick your friends into thinking you have the latest hardware trend!

Enhanced Notifications

- Android P notifications Pixel 2 XL 4 840x560 - Developers: Here’s how to prepare your app for Android P

Android P brings more functionality to notifications, too:

  • Display in your message notifications via setData().
  • Use the new person class to more easily get information about the contacts involved in a conversation
  • Identify whether a conversation comes from a group conversation by using setGroupConversation() to identify it as such
  • Set semantic actions for intents with the setSemanticAction() method (for “read,” “delete,” “reply”)

Android P also makes it easier for you to manage the Notification Channels introduced in Oreo. You can query the current settings for a channel group using getNotificationChannelGroup() and check whether the group is blocked with isBlocked().

Other Features and Changes for Devs

There are more new features for devs too. The AnimatedImageDrawable class will show GIF and WebP images without an external library for example. ImageDecoder is here to replace BitmapFactory. At a glance, it doesn’t look to cut down on the boilerplate all that much to just display an image, but it does have handy methods like setResize() and setCrop(). And it allows you to add some cool effects such as rounded corners and circle masks with setPostProcessor(). This can also be used in conjunction with AnimatedImageDrawable to add rounded edges to GIFs. So that’s cool.

The AnimatedImageDrawable class lets you show GIF and WebP images without an external library

For those taking advantage of onboard machine learning, the Neural Networks API introduced in Android 8.1 has been upgraded with nine new ops.

There are plenty more little tweaks and upgrades too, so get it the full of features from horse’s mouth here.

Closing Thoughts

- Android P notifications Pixel 2 XL 3 840x560 - Developers: Here’s how to prepare your app for Android P

There’s definitely some work to do, especially if you have an app that uses background services or sends a lot of data. Those with simple games or utilities probably won’t have too much homework to do, though you might want to see how they look with the notch cutout.

There are a few nice goodies thrown in there for good measure too, which will hopefully make your life easier and allow you to provide your loyal users with a better .



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here