Tag Archives: Develop

API 23 SDK now available for Android Wear

Posted by Wayne Piekarski, Developer Advocate

The new LG Watch Urbane 2nd Edition LTE is the first watch to run Android 6.0 Marshmallow (API 23) for Android Wear. Currently, all other Android Wear watches implement API 22, and in the coming months, these will receive an OTA update for API 23 as well.

So what does this mean for you as an Android Wear developer? You will need to ensure that your apps are compatible with both API 23 and API 22 watches. While you can start implementing the new features in this post, you still need to maintain backwards compatibility until all watches are upgraded.

New permissions model and samples

API 23 introduces a new runtime permissions model for both phones and watches. The new permissions model allows users to pick and choose which permissions to grant apps at the time of use. In addition, new permissions settings allow users to turn on and off app permissions at any time.

To use the new permissions model on Wear, read Permissions on Android Wear. This training guide provides an in-depth discussion of Wear-specific scenarios, such as when your Wear app relies on a phone-side permission. In addition, all of the Android Wear samples have been updated to use the new permissions model, and a new RuntimePermissionsWear sample shows how to handle permission requests across devices.

When you are ready, you can update your application on both the phone and watch side to use compileSdkVersion 23 and targetSdkVersion 23. Make sure that you check and request the permissions needed by your app at runtime, on both the phone and the watch. It is important that you do not change targetSdkVersion to 23 until you have implemented the permission checks properly, since it changes how the system installs and runs the app. For example, an API call that might have previously returned a result could now fail, causing the app to behave in unexpected ways.

-round and -notround resource qualifiers

API 23 makes it easier to build apps for both round and square Android Wear watches. We listened to your feedback and added new resource qualifiers for -round and -notround, so you can use the resource system to load the appropriate images, layouts, and strings based on the type of watch you are working with. You can also combine this with existing resource qualifiers -hdpi, -tvdpi, -280dpi, and -360dpi for the various Android Wear watches that are currently available. All of the existing classes in the wearable UI library, such as WatchViewStub, BoxInsetLayout, and WearableFrameLayout will continue to work as well, so you do not need to change your code. The -round and -notround resource qualifiers will not work on API 22 devices, so you cannot assume they will be available until all devices are on API 23.

Watches with speakers

The LG Watch Urbane 2nd Edition LTE is the first watch to include speaker support, so you can now add sounds to your Wear app. You can play audio files using the same APIs that are available on Android phones, such as AudioTrack, MediaPlayer, and ExoPlayer. Check out the sample and documentation to learn how to detect when the speaker is available on a Wear device and play sounds through it.

Intel x86 support

The new TAG Heuer Connected, along with other upcoming Android Wear watches, is based on Intel x86 processors. If you are working only with Java code, your apps will automatically work on any architecture. However, if you’re using the NDK, you’ll need to provide both armeabi-v7a and x86 shared libraries in your wearable APK. Since only one wearable app can be bundled in a phone app, it is not possible to deliver different APKs to different watches based on architecture. If your wearable APK is missing an x86 library, it will fail to install on x86 watches with INSTALL_FAILED_NO_MATCHING_ABIS and code -113.

If you are using Android Studio, you will need to adjust your build.gradle file to include:

ndk {
  abiFilters = ['armeabi-v7a','x86']
}

If you are using the NDK directly, you will need to modify your Application.mk file to use:

APP_ABI := armeabi-v7a x86

These changes should only be made for the wearable APK, and you can continue to support other ABIs on the phone side. You can test your application by checking if it works on the x86 emulator provided by the SDK Manager.

Updated emulator

New Android Wear emulator images for API 23 and x86 watches are available to download from the SDK Manager in Android Studio. We have also added profiles that represent every available Android Wear watch, so you can easily test on any device you want. It is also important that you understand and test all the combinations of phones (API <= 22, API = 23) and wearables (API 22, API 23), so that your app works for all users.

Updates to existing watches

The new emulator images allow you to get started immediately with testing and deploying updated apps for users with API 23 watches. The schedule for updating existing Android Wear watches via OTA updates has not been announced yet. We will announce the update schedule on the Android Wear Developers Google+ community. We’ll also let you know when the rollout is complete, and API 22 support for Android Wear is no longer needed.

Google Developers teams up with General Assembly to launch Android Development Immersive training course

Posted by Peter Lubbers, Senior Program Manager, Google Developer Training

Today at the Big Android BBQ we announced that we have teamed up with General Assembly (GA), a global education institution transforming thinkers into creators, to create a new Android Development Immersive training course. This 12-week, full-time course will be offered beginning in January 2016 at GA’s New York campus, and in February at GA’s San Francisco campus and will roll out to additional campuses over the course of the next year. It is the first in-person training program of its kind that Google Developers has designed and built.

The Google Developer Relations team teamed up with General Assembly to ensure the Android Development Immersive bootcamp provides developers with access to the best instructors and latest and greatest hands-on material to create successful app experiences and businesses. To effectively reach over a billion of Android users globally, it's important for developers to build high-quality apps that are beautifully designed, performant, and delightful to use.

“We are constantly looking at the economy and job market for what skills are most in-demand. Demand for developers who can address this market and build new applications is tremendous,” said Jake Schwartz, co-founder and CEO, General Assembly. “Developing this course in partnership with Google Developers allows us to provide students with the most relevant skills, ensuring a reliable pipeline of talented developers ready to meet the urgent demand of companies in the Android ecosystem, a key component of GA's education-to-employment model."

Registration in the Android Development Immersive includes access to GA’s career preparation services and support, also known as Outcomes, includes assistance in creating portfolio-ready projects, access to career development workshops, networking events, and coaching and support in the job search process. Through in-person hiring events, mock interviews & GA’s online job search platform, graduates connect with GA’s hiring partners, which consists of close to 2,000 employers globally.

One of these employers is Vice Media. "I'm really excited to see the candidates coming out of the GA Android course. The fact that they're working with both Google and potential employers to shape the curriculum around real-world problems will make a huge difference. Textbook learning is one thing, but classroom learning with practitioners is a level we have all been waiting for. In fact, Vice Media is going to be hiring an apprentice right out of this course," said Ben Jackson, Director of Mobile Apps for Vice Media.

Learn more and sign up here.

Android Support Library 23.1

Posted by Ian Lake, Developer Advocate

The Android Support Library is a collection of libraries available on a wide array of API levels that help you focus on the unique parts of your app, providing pre-built components, new functionality, and compatibility shims.

With the latest release of the Android Support Library (23.1), you will see improvements across the Support V4, Media Router, RecyclerView, AppCompat, Design, Percent, Custom Tabs, Leanback, and Palette libraries. Let’s take a closer look.

Support V4

The Support V4 library focuses on making supporting a wide variety of API levels straightforward with compatibility shims and backporting specific functionality.

NestedScrollView is a ScrollView that supports nested scrolling back to API 4. You’ll now be able to set a OnScrollChangeListener to receive callbacks when the scroll X or Y positions change.

There are a lot of pieces that make up a fully functioning media playback app, with much of it centered around MediaSessionCompat. A media button receiver, a key part to handling playback controls from hardware or bluetooth controls, is now formalized in the new MediaButtonReceiver class. This class makes it possible to forward received playback controls to a Service which is managing your MediaSessionCompat, reusing the Callback methods already required for API 21+, centralizing support on all API levels and all media control events in one place. A simplified constructor for MediaSessionCompat is also available, automatically finding a media button receiver in your manifest for use with MediaSessionCompat.

Media Router

The Media Router Support Library is the key component for connecting and sending your media playback to remote devices, such as video and audio devices with Google Cast support. It also provides the mechanism, via MediaRouteProvider, to enable any application to create and manage a remote media playback device connection.

In this release, MediaRouteChooserDialog (the dialog that controls selecting a valid remote device) and MediaRouteControllerDialog (the dialog to control ongoing remote playback) have both received a brand new design and additional functionality as well. You’ll find the chooser dialog sorts devices by frequency of use and includes a device type icon for easy identification of different devices while the controller dialog now shows current playback information (including album art).

To feel like a natural part of your app, the content color for both dialogs is now based on the colorPrimary of your alert dialog theme:

<!-- Your app theme set on your Activity -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <item name="colorPrimary">@color/primary</item>
  <item name="colorPrimaryDark">@color/primaryDark</item>
  <item name="alertDialogTheme">@style/AppTheme.Dialog</item>
</style>
<!-- Theme for the dialog itself -->
<style name="AppTheme.Dialog" parent="Theme.AppCompat.Light.Dialog.Alert">
  <item name="colorPrimary">@color/primary</item>
  <item name="colorPrimaryDark">@color/primaryDark</item>
</style>

RecyclerView

RecyclerView is an extremely powerful and flexible way to show a list, grid, or any view of a large set of data. One advantage over ListView or GridView is the built in support for animations as items are added, removed, or repositioned.

This release significantly changes the animation system for the better. By using the new ItemAnimator’s canReuseUpdatedViewHolder() method, you’ll be able to choose to reuse the existing ViewHolder, enabling item content animation support. The new ItemHolderInfo and associated APIs give the ItemAnimator the flexibility to collect any data it wants at the correct point in the layout lifecycle, passing that information into the animate callbacks.

Note that this new API is not backward compatible. If you previously implemented an ItemAnimator, you can instead extend SimpleItemAnimator, which provides the old API by wrapping the new API. You’ll also notice that some methods have been entirely removed from ItemAnimator. For example, if you were calling recyclerView.getItemAnimator().setSupportsChangeAnimations(false), this code won’t compile anymore. You can replace it with:

ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
  ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}

AppCompat

One component of the AppCompat Support Library has been in providing a consistent set of widgets across all API levels, including the ability to tint those widgets to match your branding and accent colors.

This release adds tint aware versions of SeekBar (for tinting the thumb) as well as ImageButton and ImageView (providing backgroundTint support) which will automatically be used when you use the platform versions in your layouts. You’ll also find that SwitchCompat has been updated to match the styling found in Android 6.0 Marshmallow.

Design

The Design Support Library includes a number of components to help implement the latest in the Google design specifications.

TextInputLayout expands its existing functionality of floating hint text and error indicators with new support for character counting.

AppBarLayout supports a number of scroll flags which affect how children views react to scrolling (e.g. scrolling off the screen). New to this release is SCROLL_FLAG_SNAP, ensuring that when scrolling ends, the view is not left partially visible. Instead, it will be scrolled to its nearest edge, making fully visible or scrolled completely off the screen. You’ll also find that AppBarLayout now allows users to start scrolling from within the AppBarLayout rather than only from within your scrollable view - this behavior can be controlled by adding a DragCallback.

NavigationView provides a convenient way to build a navigation drawer, including the ability to creating menu items using a menu XML file. We’ve expanded the functionality possible with the ability to set custom views for items via app:actionLayout or using MenuItemCompat.setActionView().

Percent

The Percent Support Library provides percentage based dimensions and margins and, new to this release, the ability to set a custom aspect ratio via app:aspectRatio. By setting only a single width or height and using aspectRatio, the PercentFrameLayout or PercentRelativeLayout will automatically adjust the other dimension so that the layout uses a set aspect ratio.

Custom Tabs

The Custom Tabs Support Library allows your app to utilize the full features of compatible browsers including using pre-existing cookies while still maintaining a fast load time (via prefetching) and a custom look and actions.

In this release, we’re adding a few additional customizations such as hiding the url bar when the page is scrolled down with the new enableUrlBarHiding() method. You’ll also be able to update the action button in an already launched custom tab via your CustomTabsSession with setActionButton() - perfect for providing a visual indication of a state change.

Navigation events via CustomTabsCallback#onNavigationEvent() have also been expanded to include the new TAB_SHOWN and TAB_HIDDEN events, giving your app more information on how the user interacts with your web content.

Leanback

The Leanback library makes it easy to build user interfaces on TV devices. This release adds GuidedStepSupportFragment for a support version of GuidedStepFragment as well as improving animations and transitions and allowing GuidedStepFragment to be placed on top of existing content.

You’ll also be able to annotate different types of search completions in SearchFragment and staggered slide transition support for VerticalGridFragment.

Palette

Palette, used to extract colors from images, now supports extracting from a specific region of a Bitmap with the new setRegion() method.

SDK available now!

There’s no better time to get started with the Android Support Library. You can get started developing today by updating the Android Support Repository from the Android SDK Manager.

For an in depth look at every API change in this release, check out the full API diff.

To learn more about the Android Support Library and the APIs available to you through it, visit the Support Library section on the Android Developer site.

Android Studio 1.4

Posted by, Jamal Eason, Product Manager, Android

Today we are releasing the 1.4 update to the Android Studio stable release channel. Most of the work and enhancements for Android Studio 1.4 are under the hood. However we have a handful of new features that we hope you enjoy and integrate into your workflow.

New Features in Android Studio 1.4


Design Tools
  • Vector Assets

    Starting with API 21, you can use Vector Drawables for image assets. For most apps, using VectorDrawables decreases the amount of density dependent drawables you need to maintain, and will also give you sharp image assets regardless of the screen device densities your app supports.

    With Android Studio 1.4, we are making the process of importing SVG images or Material icons much easier. If you update your gradle android plugin to 1.4.0-beta3 (or higher) in the project structure dialogue or your project build.gradle file ( 'com.android.tools.build:gradle:1.4.0-beta3' ), you can now use the new Vector Asset Studio by right-clicking the res/drawable folder in your project and selecting New → Vector Asset from the content menu.

    We are also excited to offer backwards compatibility for your vector assets in Android Studio 1.4. Once you have a vectorDrawable image in your res/drawable, Android Studio will automatically generate raster PNG images for API level 20 and below during build time. This means you only need to update and maintain your vector asset for your app project and Android Studio can take care of image conversion process. Note, it is still best practice to create density dependent launcher icons in your res/mipmap folder. Learn more by watching the DevByte video on the new Vector Asset Studio tool.


  • Theme Editor

    We understand that managing your app theme and style can be a bit complex. With Android Studio 1.4, we are releasing a preview of the Theme Editor to help with this task. This first version of the Theme Editor is focused on editing and updating the material theme colors (colors.xml) in your app project. In future releases, we will cover more attributes of your app theme and styles files. To access the editor, navigate from top level menu Tools → Android → Theme Editor.

  • Project Templates

    We know many of you use the New Project Wizard app templates to start a new app project or to quickly add an activity to an existing app. To help with the visual design of your apps, we updated the app templates to include the Android Design Support Library alongside the AppCompat Support library.

    From the template wizard you can start projects with a basic blank template with a floating action button or start from a range of user interface components such as the navigation drawer, or AppBar with scrolling view. We also re-introduced the empty app template for those who want minimum code generation when adding an activity to your project.

    With Android Studio 1.4, you can also validate your apps on the new Nexus 5X and Nexus 6P screen sizes.

Performance Monitors

  • GPU Rendering Monitor

    Now it is possible to quickly inspect the GPU rendering performance of your app. To enable GPU monitoring, make sure you turn on monitoring for your Android hardware device or emulator under Setting → Developer Options → Profile GPU rendering → In adb shell dumpsys gfxinfo . To learn more about the GPU rendering results, check out the developer documentation.

  • Network Monitor

    With Android Studio 1.4, you can also monitor the network usage of your app. With the monitor you can track the transmit and receive rates of your app over time.

Developer Services

  • Firebase

    It is now even easier to add a Firebase mobile backend to your Android app. Firebase includes data storage, user authentication, static hosting, and more. To access the feature, navigate from the top level menu and select File → Project Structure → Cloud. Learn more about Firebase in this tutorial.

Whats Next

For current developers on Android Studio, you can check for updates from the navigation menu (Help → Check for Update [Windows/Linux] , Android Studio → Check for Updates [OS X]) . For new users, you can learn more about Android Studio on the product overview page or download the stable version from the Android Studio download site.

We welcome feedback on how we can help you. Connect with the Android developer tools team on Google+.

Android 6.0 Marshmallow coming to devices soon

Posted by, Dave Burke, VP of Engineering, Android

Starting next week, Android 6.0 Marshmallow will begin rolling out to supported Nexus devices around the world, including Nexus 5, Nexus 6, Nexus 7 (2013), Nexus 9, Nexus Player, and Android One. At the same time, we’ll be pushing the Android 6.0 source to the Android Open Source Project (AOSP), which marks the official beginning of public availability.

Today we also introduced two great new Nexus devices that will be among the first to run the Android 6.0 Marshmallow platform. These devices let your apps use the latest platform features and take advantage of the latest hardware optimizations from our partners. Let’s take a look at how to make sure your apps look great on these new devices.

Introducing Nexus 5X and Nexus 6P

Nexus 5X
Nexus 6P

The Nexus 5X is built in partnership with LG. It’s equipped with a 5.2-inch FHD LCD 1080p display, a Snapdragon™ 808 processor (1.8 GHz hexa-core, 64-bit), and a 12.3 MP rear camera. Offering top-line performance in a compact, lightweight device.

The Nexus 6P, built in partnership with Huawei, has a 5.7-inch WQHD AMOLED display, Snapdragon™ 810 v2.1 processor (2.0 GHz octa-core 64-bit), front-facing stereo speakers, and a 12.3 MP rear camera, all housed in a diamond-cut aluminum body.

Both devices have USB Type-C ports and fingerprint sensors, and include the latest hardware features for Android, such as: Android Sensor Hub, low-power Wi-Fi scanning with channel selection, batching, and BSSID hotlists, Bluetooth 4.2 with ultra low-power BLE notifications, and more.

Get your apps ready

Take some time to make sure your apps and games are ready to give your users the best mobile experience on these devices.

Check your assets

Resolution Screen size Density
Nexus 5x 1920 x 1080 px (730 x 410 dp) normal 420 dpi
Nexus 6P 2560 x 1440 px (730 x 410 dp) normal 560 dpi

Nexus 5X has a quantized density of 420 dpi, which falls in between the xhdpi and xxhdpi primary density buckets. Nexus 6P has a density of 560 dpi, which falls in between the xxhdpi and xxxhdpi buckets. The platform will scale down any assets from a higher resolution bucket, but if those aren’t available, then it will scale up the assets from a lower-density bucket.

For best appearance in the launcher, we recommend that you provide at least an xxxhdpi app icon because devices can display large app icons on the launcher.

For the rest of your assets, you can consider using vector assets or optionally add versions for the next-higher density bucket. This provides a sharper visual experience, but does increase apk size, so you should make an appropriate decision for your app.

Make sure you are not filtered on Google Play

If you are using the <compatible-screens>: element in your AndroidManifest.xml file, you should stop using it because it’s not scalable to re-compile and publish your app each time new devices come out. If you must use it, make sure to update your manifest to add a new configuration for Nexus 5X, since it uses a new density bucket (420). Otherwise, your app may be filtered from Google Play on these devices.

Wrapping up M Developer Preview

After three preview releases, and with the final OTA coming soon, it’s time to wrap up the Android M Developer Preview. The feedback you’ve provided has helped make Android 6.0 a great platform for apps and games. Developers in more than 200 countries have been using the Developer Preview to get their apps ready for Android 6.0 Marshmallow users everywhere.

More developer resources

If you haven’t taken a look at Android 6.0 Marshmallow yet, visit developer.android.com/mm for complete information about about what’s new for developers and important changes to plan for in your apps — runtime permissions, Doze and App Standby idle modes, Auto Backup for Apps, fingerprint support, and others.

We’ve also produced a playlist of developer videos to help you get the most out of all the new features in Android 6.0 Marshmallow. Check it out below.

Final testing and updates

Now is the time to finish up testing and prepare for publishing. You can use the Developer Preview 3 system images for final testing until early October. After the Android 6.0 public release, you’ll be able to download final images from the Nexus factory images page, and final emulator images from Android Studio.

Reminder: Devices flashed with an M Developer Preview build won’t receive the Android 6.0 update automatically. You’ll need to manually flash those devices to a public released image first.

Upload your apps to Google Play

When your apps are ready, you can update them to Google Play via the Developer Console on all release channels (Alpha, Beta & Production). For apps that target API level 23, Google Play will provide the new optimized download and autoupdate flow based on the runtime permissions model in Android 6.0. Give it a try!

To make sure that your updated app runs well on Android 6.0 Marshmallow and older versions, we recommend that you use the newly improved beta testing feature on Google Play to get early feedback. You can then do a staged rollout as you release the new version to all users.

What’s next?

In mid-October, we’ll be turning down the M Developer Preview community and the M Developer Preview issue tracker. If the you filed bugs against the preview that you want to leave open against the Android 6.0 final builds, you can file a new issue in the AOSP issue tracker.

Thanks to everyone who participated in the Android M Developer Preview. Let us know how this year’s preview met your needs by taking a short survey. Your feedback helps shape our future releases.


Introducing Android Developer Nanodegree in India with Udacity—1000 scholarships available

Originally posted on the Google India blog

Posted by Peter Lubbers, Senior Program Manager, Google

With a vision to transform India into a hub of high-quality mobile developers for global and local apps, we’re delighted to announce the launch of a program to offer Android Developer Nanodegrees in India in partnership with Udacity. The Android Nanodegree is an education credential that is designed to help developers learn new skills and advance their careers in a few months—from anywhere on any device—at their own pace.

The Udacity Android Nanodegree program comprises of courses developed and taught by expert Google instructors from the Google Developer Relations team and will include project reviews, mentorship and career services from Udacity. The curriculum will be updated regularly with new releases and will provide developers with a certificate that will help them to be a more marketable Android developer.

With 3 million software developers, India is already the second largest developer population in the world, but we still lag behind in creating world-class apps. With the launch of this program we want to bridge the gap by providing India’s developer community with an easy way to learn and build high quality apps for the world. Today, only less than 2% of apps built in India feature in top 1000 apps globally and our goal is to raise this to 10% in next three years.


The Udacity Android Nanodegree program is open for enrollment from today. The program takes an average of 6-9 months to complete and costs Rs. 9,800 per month with Udacity refunding 50 percent of the tuition upon completion. Google and Tata Trusts have partnered to give 1000 scholarships for the Android Nanodegree to deserving students and will be available from today. Interesting applicants can visit https://www.udacity.com/india for more information.

Speaking about their association with the Android Nanodegree program, Mr. Venkat - Managing Director of Tata Trusts said, “India has one of the youngest population of developers, where the average age of a developer is just 25 years old. While the last decade has established India as the largest provider of a skilled IT workforce to the world, there is an opportunity to help our young developers and equip them to compete on a global stage through educational and skill building programs. As part of our association, we’re glad to announce 500 free scholarships for the complete Android Nanodegree."

Chrome custom tabs smooth the transition between apps and the web

Originally posted on the Chromium blog

Posted by Yusuf Ozuysal, Chief Tab Customizer

Android app developers face a difficult tradeoff when it comes to showing web content in their Android app. Opening links in the browser is familiar for users and easy to implement, but results in a heavy-weight transition between the app and the web. You can get more granular control by building a custom browsing experience on top of Android’s WebView, but at the cost of more technical complexity and an unfamiliar browsing experience for users. A new feature in the most recent version of Chrome called custom tabs addresses this tradeoff by allowing an app to customize how Chrome looks and feels, making the transition from app to web content fast and seamless.

Chrome custom tabs with pre-loading vs. Chrome and WebView

Chrome custom tabs allow an app to provide a fast, integrated, and familiar web experience for users. Custom tabs are optimized to load faster than WebViews and traditional methods of launching Chrome. As shown above, apps can pre-load pages in the background so they appear to load nearly instantly when the user navigates to them. Apps can also customize the look and feel of Chrome to match their app by changing the toolbar color, adjusting the transition animations, and even adding custom actions to the toolbar so users can perform app-specific actions directly from the custom tab.

Custom tabs benefit from Chrome’s advanced security features, including its multi-process architecture and robust permissions model. They use the same cookie jar as Chrome, allowing a familiar browsing experience while keeping users’ information safe. For example, if a user has signed in to a website in Chrome, they will also be signed in if they visit the same site in a custom tab. Other features that help users browse the web, like saved passwords, autofill, Tap to Search, and Sync, are also available in custom tabs.



Custom tabs are easy for developers to integrate into their app by tweaking a few parameters of their existing VIEW intents. Basic integrations require only a few extra lines of code, and a support library makes more complex integrations easy to accomplish, too. Since custom tabs is a feature of Chrome, it’s available on any version of Android where recent versions of Chrome are available.

Users will begin to experience custom tabs in the coming weeks in Feedly, The Guardian, Medium, Player.fm, Skyscanner, Stack Overflow, Tumblr, and Twitter, with more coming soon. To get started integrating custom tabs into your own application, check out the developer guide.

Announcing the Android Auto Desktop Head Unit

Posted by Josh Gordon, Developer Advocate

Today we’re releasing the Desktop Head Unit (DHU), a new testing tool for Android Auto developers. The DHU enables your workstation to act as an Android Auto head unit that emulates the in-car experience for testing purposes. Once you’ve installed the DHU, you can test your Android Auto apps by connecting your phone and workstation via USB. Your phone will behave as if it’s connected to a car. Your app is displayed on the workstation, the same as it’s displayed on a car.

The DHU runs on your workstation. Your phone runs the Android Auto companion app.

Now you can test pre-released versions of your app in a production-like environment, without having to work from your car. With the release of the DHU, the previous simulators are deprecated, but will be supported for a short period prior to being officially removed.

Getting started

You’ll need an Android phone running Lollipop or higher, with the Android Auto companion app installed. Compile your Auto app and install it on your phone.

Install the DHU

Install the DHU on your workstation by opening the SDK Manager and downloading it from Extras > Android Auto Desktop Head Unit emulator. The DHU will be installed in the <sdk>/extras/google/auto/ directory.

Running the DHU

Be sure your phone and workstation are connected via USB.

  1. Enable Android Auto developer mode by starting the Android Auto companion app and tapping on the header image 10 times. This is a one-time step.
  2. Start the head unit server in the companion app by clicking on the context menu, and selecting “Start head unit server”. This option only appears after developer mode is enabled. A notification appears to show the server is running.
  3. Start the head unit server in the Android Auto companion app before starting the DHU on your workstation. You’ll see a notification when the head unit server is running.

  4. On your workstation, set up port forwarding using ADB to allow the DHU to connect to the head unit server running on your phone. Open a terminal and type adb forward tcp:5277 tcp:5277. Don’t forget this step!
  5. Start the DHU.   cd <sdk>/extras/google/auto/   On Linux or OSX: ./desktop-head-unit   On Windows, desktop-head-unit.exe

At this point the DHU will launch on your workstation, and your phone will enter Android Auto mode. Check out the developer guide for more info. We hope you enjoy using the DHU!

Building better apps with Runtime Permissions

Posted by Ian Lake, Developer Advocate

Android devices do a lot, whether it is taking pictures, getting directions or making phone calls. With all of this functionality comes a large amount of very sensitive user data including contacts, calendar appointments, current location, and more. This sensitive information is protected by permissions, which each app must have before being able to access the data. Android 6.0 Marshmallow introduces one of the largest changes to the permissions model with the addition of runtime permissions, a new permission model that replaces the existing install time permissions model when you target API 23 and the app is running on an Android 6.0+ device.

Runtime permissions give your app the ability to control when and with what context you’ll ask for permissions. This means that users installing your app from Google Play will not be required to accept a list of permissions before installing your app, making it easy for users to get directly into your app. It also means that if your app adds new permissions, app updates will not be blocked until the user accepts the new permissions. Instead, your app can ask for the newly added runtime permissions as needed.

Finding the right time to ask for runtime permissions has an important impact on your app’s user experience. We’ve gathered a number of design patterns in our new Permission design guidelines including best practices around when to request permissions, how to explain why permissions are needed, and how to handle permissions being denied.

Ask up front for permissions that are obvious

In many cases, you can avoid permissions altogether by using the existing intents system to utilize other existing specialized apps rather than building a full experience within your app. An example of this is using ACTION_IMAGE_CAPTURE to start an existing camera app the user is familiar with rather than building your own camera experience. Learn more about permissions versus intents.

However, if you do need a runtime permission, there’s a number of tools to help you. Checking for whether your app has a permission is possible with ContextCompat.checkSelfPermission() (available as part of revision 23 of the support-v4 library for backward compatibility) and requesting permissions can be done with requestPermissions(), bringing up the system controlled permissions dialog to allow the user to grant you the requested permission(s) if you don’t already have them. Keep in mind that users can revoke permissions at any time through the system settings so you should always check permissions every time.

A special note should be made around shouldShowRequestPermissionRationale(). This method returns true if the user has denied your permission request at least once yet have not selected the ‘Don’t ask again’ option (which appears the second or later time the permission dialog appears). This gives you an opportunity to provide additional education around the feature and why you need the given permission. Learn more about explaining why the app needs permissions.

Read through the design guidelines and our developer guide for all of the details in getting your app ready for Android 6.0 and runtime permissions. Making it easy to install your app and providing context around accessing user’s sensitive data are key changes you can make to build better apps.

Get the Do’s and Don’ts for Notifications from Game Developer Seriously

Posted by Lily Sheringham, Developer Marketing at Google Play

Editor’s note: We’ve been talking to developers to find out how they’ve been achieving success on Google Play. We recently spoke to Reko Ukko at Finnish mobile game developer, Seriously, to find out how to successfully use Notifications.

Notifications on Android let you send timely, relevant, and actionable information to your users' devices. When used correctly, notifications can increase the value of your app or game and drive ongoing engagement.

Seriously is a Finnish mobile game developer focused on creating entertaining games with quality user experiences. They use push notifications to drive engagement with their players, such as helping players progress to the next level when they’ve left the app after getting stuck.

Reko Ukko, VP of Game Design at Seriously, shared his tips with us on how to use notifications to increase the value of your game and drive ongoing engagement.

Do’s and don’ts for successful game notifications

Do’s

Don’ts

Do let the user get familiar with your service and its benefits before asking for permission to send notifications.

Don’t treat your users as if they’re all the same - identify and group them so you can push notifications that are relevant to their actions within your app.

Do include actionable context. If it looks like a player is stuck on a level, send them a tip to encourage action.

Don’t spam push notifications or interrupt game play. Get an understanding of the right frequency for your audience to fit the game.

Do consider re-activation. If the player thoroughly completes a game loop and could be interested in playing again, think about using a notification. Look at timing this shortly after the player exits the game.

Don’t just target players at all hours of the day. Choose moments when players typically play games – early morning commutes, lunch breaks, the end of the work day, and in the evening before sleeping. Take time zones into account.

Do deep link from the notification to where the user expects to go to based on the message. For example. if the notification is about "do action X in the game now to win", link to where that action can take place.

Don’t forget to expire the notifications if they’re time-limited or associated with an event. You can also recycle the same notification ID to avoid stacking notifications for the user.

Do try to make an emotional connection with the player by reflecting the style, characters, and atmosphere of your game in the notification. If the player is emotionally connected to your game, they’ll appreciate your notifications and be more likely to engage.

Don’t leave notifications up to guess work. Experiment with A/B testing and iterate to compare how different notifications affect engagement and user behavior in your app. Go beyond measuring app opening metrics – identify and respond to user behavior.

Experiment with notifications yourself to understand what’s best for your players and your game. You can power your own notifications with Google Cloud Messaging, which is free, cross platform, reliable, and thoughtful about battery usage. Find out more about developing Notifications on Android.