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.



Note that some of new features (e.g. vector assets) require you to use Gradle Plugin 1.4 for your app project. The beta version of the Gradle plugin (1.4.0-beta3 ) is available today on jcenter with the final version coming in the next few weeks.




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, the Gradle plugin 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+.

Committing to RCS, the latest standard in carrier messaging

Mobile messaging has never been more central to people’s lives, and there is an incredible amount of innovation happening with chat applications across the mobile ecosystem. SMS carrier messaging is used by billions of people every day and enables people to reach anyone around the world, regardless of their device, carrier, app or location. However, the features available in SMS haven’t kept up with modern messaging apps. Rich Communications Services (RCS) is a new standard for carrier messaging and brings many of the features that people now expect from mobile messaging, such as group chats, high res photos and more.

Many leaders in the wireless industry have already put great work into laying the foundation for RCS, and we’ve heard from many of them that there are ways Android can help. We’re excited to team up with mobile operators, device makers and the rest of the Android ecosystem to support RCS standards and help accelerate their deployment in a more consistent way. We’re already working closely with many of our partners on implementing RCS, and look forward to growing the RCS ecosystem together.

As part of this commitment, we’re also very excited to announce that the Jibe Mobile team is joining Google to help us bring RCS to a global audience. Jibe is a leading provider of RCS services and they’ll continue helping carriers easily deploy RCS to their users. We can’t wait to work with them and build on the great work that they’ve already done.

Deploying RCS to create an even better messaging experience on Android will take time and collaboration throughout the wireless industry, but we’re excited to get started.

Posted by Mike Dodd, Android RCS Software Engineer and Minister of Messaging

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 you've filed bugs against the preview, and you'd like to keep these 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.









S’more to love across all your screens

(Cross posted on the Official Google Blog)

From your watch to your phone to your TV, we want to help you stay connected, entertained and informed across all your screens. Today we’re introducing a few new things that do just that: two Nexus phones, a tablet for work and play, updates to Chromecast and features for some of your favorite apps—all working together to make your day a little bit easier and more fun.
New Nexus phones
We made Android to be an open platform that anyone can build on, and today there are 4,000+ Android devices in all shapes and sizes. Android’s diversity is why it’s become the most popular mobile platform in the world, and the latest version, Marshmallow, takes Android to a new level of performance.

While we love all the Android devices out there, every year we build Nexus devices to show off the latest and greatest, directly from the people who built Android. Today we’re introducing the latest Nexus treats, both running Marshmallow, sweetened by amazing apps and sandwiched by some cutting-edge hardware (see what we did there?):
  • Nexus 6P is the first all-metal-body Nexus phone. Built in collaboration with Huawei, this 5.7” phone is crafted from aeronautical-grade aluminum, with a USB Type-C port for fast charging, a powerful 64-bit processor, and a 12.3 MP camera sensor with massive 1.55ยตm pixels (hello, better photos!). The Nexus 6P starts at $499.
  • You’re not the only one who misses your Nexus 5. We’ve joined forces with LG to bring it back with the new Nexus 5X, which gives you great performance in a compact and light package, with a beautiful 5.2” screen and the same 12.3 MP camera and Type-C port as the Nexus 6P. Nexus 5X starts at $379.

Both phones include a new fingerprint sensor, Nexus Imprint, which gives you quick and secure access to your phone, as well as use of Android Pay (in the U.S.). They are available for pre-order on the Google Store from a number of countries, including the U.S., U.K., Ireland and Japan, and come with a free 90-day subscription to Google Play Music. In the U.S., pre-orders include a $50 Play credit to help you stock up your favorite music, apps, games and shows. And, finally, for you Project Fi fans out there, you'll be happy to know Nexus 6P and Nexus 5X will work on your favorite network. Request an invite to our Early Access Program at fi.google.com.
Pixel C
We’re expanding the Pixel family by introducing the first Android tablet built end-to-end by Google. The Pixel C brings together the benefits of a full-size keyboard with the portability of a tablet. The tablet and keyboard attach magnetically (no docking mechanism FTW), so it’s easy to switch between typing and using the touch screen.

And if you’re familiar with the Chromebook Pixel, you’ll immediately see the family resemblance: the Pixel C has the same beautiful aluminum design, great display and USB Type-C port. The Pixel C will be available in time for the holidays on the Google Store.

Cast ALL the things
Today we’re introducing two new Chromecast devices. The new Chromecast has a fresh design, and is easier to plug into TVs with crowded ports. It supports the latest Wi-Fi standards and adapts more easily to changing Wi-Fi conditions in your home, so you get higher quality video with less buffering. Most importantly, we added two new colors. ;)

Chromecast Audio is a small device that plugs into your existing speakers, so you can stream your favorite music, radio and podcasts over Wi-Fi, similar to Chromecast. It works with tons of apps, including Spotify, Pandora and Google Play Music. Just like Chromecast, it works from anywhere in your home with your favorite devices, including Android, iOS, and laptops. And it’s available on the Google Store and other online retailers for just $35—way less than most Wi-Fi speakers today.
We’ve also updated the Chromecast app to make it easier for you to find great things to watch or to play, across the thousands of apps that work with Chromecast—whether you feel like browsing or want to search for a specific TV show or movie. For Cast-enabled apps that aren’t already on your phone, we’ll suggest one for you. The updated Chromecast app is rolling out on Android and iOS over the next few weeks.



Your favorite apps... for the whole family
All your shiny devices get even better when you have great apps to go with them. So we’re making a few updates to Google Play Music and Google Photos.
First, Google Play Music will offer a new family plan later this year. Up to six people will be able to use one account for a shared fee of $14.99 a month (instead of $9.99 per person). Get the dance party ready.

Sharing is a theme of today’s Google Photos updates, too. We’re adding Chromecast support to give you that old-school slideshow experience—dimmed lights optional. In the U.S., you can now add private labels to your photos to make it easier to search for specific pics of people with things, places or other people—say, that photo of Mom at the Grand Canyon, or of your daughter with her pet bunny. And soon you’ll be able to pool all your photos and videos with friends and family in one place, and get updates as soon as new photos are added. Best of all, there’s no setup involved, and you can use any device. So that dance party we mentioned earlier? Now it’s easier to gather all the memories from everyone who was there.

More to love, for more people
From Nexus to Chromecast to Pixel C to Photos, these updates are more than the sum of their parts—they unite great apps with devices that are designed to support them. They’re built to work together, so they do—seamlessly, across all your screens.
Posted by Hiroshi Lockheimer, VP Android, Chromecast and Chrome OS at Google

Tap to the Red Carpet


Last week, we announced the US rollout of Android Pay. To celebrate our launch, we’re giving one lucky winner plus three of their friends a VIP trip to Mexico City that includes four seats at the premiere of the thrilling new James Bond film, Spectre from Sony Pictures.

To qualify, just tap and pay at any of the over one million locations where Android Pay is accepted across the US between September 28 and October 15, 2015. Each day that you use Android Pay earns you one entry, and you can earn up to 18 entries during the promotional period. The grand prize winner will be drawn at random on October 19, 2015, and you can find more information by visiting the official promotional page.

To start tapping your way to the red carpet, make sure you have Android Pay on your phone. If you don't have it yet, you can download Android Pay on Google Play. Good luck, and we hope to see you on the red carpet.

Posted by Sherice Torres, Marketing Director, Android Pay

For official rules, how to enter, prize restrictions, and details, click here.

Support for 100MB APKs on Google Play

Posted by Kobi Glick, Google Play team



Smartphones are powerful devices that can support diverse tasks from graphically intensive games to helping people get work done from anywhere. We understand that developers are challenged with delivering a delightful user experience that maximizes the hardware of the device, while also ensuring that their users can download, install, and open the app as quickly as possible. It’s a tough balance to strike, especially when you’re targeting diverse global audiences.



To support the growing number of developers who are building richer apps and games on Google Play, we are increasing the APK file size limit to 100MB from 50MB. This means developers can publish APKs up to 100MB in size, and users will see a warning only when the app exceeds the 100MB quota and makes use of Expansion Files. The default update setting for users will continue to be to auto-updating apps over Wi-Fi only, enabling users to access higher quality apps and games while conserving their data usage.



Even though you can make your app bigger, it doesn’t always mean you should. Remember to keep in mind the following factors:


  • Mobile data connectivity: Users around the world have varying mobile data connectivity speeds. Particularly in developing countries, many people are coming online with connections slower than those of users in countries like the U.S. and Japan. Users on a slow connection are less likely to install an app or game that is going to take a long time to download.

  • Mobile data caps: Many mobile networks around the world give users a limited number of MB that they can download each month without incurring additional charges. Users are often wary of downloading large files for fear of exceeding their limits.

  • App performance: Mobile devices have limited RAM and storage space. The larger your app or game, the slower it may run, particularly on older devices.

  • Install time: People want to start using your app or game as quickly as possible after tapping the install button. Longer wait times increase the risk they’ll give up.


We hope that, in certain circumstances, this file size increase is useful and enables you to build higher quality apps and games that users love.



Android Development Patterns: A Series on Best Practices for Android Development

Posted by, Ian Lake, Developer Advocate



One of the benefits of Android development is the flexibility provided by the large number of APIs in the Android framework and Support Library, not even including the Google Play services APIs. However, that can be a lot to understand, particularly when confronted with multiple options or design decisions. Thankfully, things are about to get a lot clearer with a new series: Android Development Patterns.



The goal of Android Development Patterns is to focus on the fundamental components and best practices that can make the biggest difference in your app. We spend time talking about the why behind each API, so that you know exactly what is best for your situation.



Centered on Android framework APIs, the Android Support Library, and high level app structure and design, we’ll augment the many videos on the Android Developers YouTube channel to bring the focus back towards Android development at its core.



Android Development Patterns are more than just videos. You’ll find written pro-tips from in-house experts at Google, such as Joanna Smith and Ian Lake, every week through the Android Development Patterns Google+ Collection.



Watch all of Android Development Patterns!



Always-on Android Wear apps with the Google Maps API

Originally posted on the Geo Developers Blog



Posted by Ankur Kotwal, Developer Advocate



Some Android Wear apps are most useful when they are always available to the user, even at a glance. Now, with Google Play Services 8.1, the Google Maps Android API supports ambient mode, the API that provides always-on capabilities. In ambient mode, the map adjusts its style to provide a simplified, low-color rendering of the map. All markers, objects, and UI controls disappear, keeping the map on the screen while letting the user know that it is not currently ready to accept user input. An important advantage is the camera position and zoom level are retained, thus keeping the user’s context within the map.



The screenshot below show how maps appear in interactive mode and in ambient mode.





To implement ambient mode in your maps, follow these steps:



  1. Set your your targetSDKVersion to 22 or higher


  2. Add the following dependencies to build.gradle for your app to add the wearable support library.

    dependencies {
    compile 'com.google.android.support:wearable:1.2.0'
    provided 'com.google.android.wearable:wearable:1.0.0'
    }



  3. Add the wearable shared library entry into the wearable app manifest:

    <application>
    <uses-library android:name="com.google.android.wearable"
    android:required="false" />
    ...
    </application>





  4. Add the WAKE_LOCK permission to the handheld and wearable app manifest:

    <uses-permission android:name="android.permission.WAKE_LOCK" />




  5. Have your Activity extend WearableActivity. This will provide the overrides that notify your app when the wearable enters, exits and provides screen updates in ambient mode.



  6. In the onCreate() method of your activity, call the setAmbientEnabled() method. This tells the framework that the app should enter ambient mode rather than returning to the watch face.


  7. Set your map to support ambient mode. You can do this by setting the attribute map:ambientEnabled="true" in the activity's XML layout file, or programmatically by setting GoogleMapOptions.ambientEnabled(true). This informs the API to pre-load necessary map tiles for ambient mode.



  8. When the activity switches to ambient mode, the system calls the onEnterAmbient() method in your wearable activity. Override onEnterAmbient() and call MapFragment.onEnterAmbient() or MapView.onEnterAmbient(). The map changes to a non-interactive, low-color rendering of the map.



  9. When in ambient mode, your app can update the display every minute by overriding onUpdateAmbient(). If you need more frequent updates, check out this guide.



  10. When the activity leaves ambient mode, the system calls the onExitAmbient() method in your wearable activity. Override onExitAmbient() and call MapFragment.onExitAmbient() or MapView.onExitAmbient(). The map returns to the normal rendering and is now ready to accept user input.





With always-on maps on Android Wear, you can now show maps at a glance. For more information on these APIs check out the documentation and the sample code.

Google Play services 8.1: Get ready for Marshmallow!

Posted by, Laurence Moroney, Developer Advocate



With the rollout of Google Play services 8.1 finally finished, there’s a lot of new information to share with developers about the release!



Marshmallow Permissions



Android 6.0 (Marshmallow) has introduced a new permissions model allowing users to control app permissions at runtime. As an app developer, it’s important for you to adopt this and give your users good control over the permissions your app needs. You can find more details here.



If your app is using Google Play services SDK versions prior to 8.1, you must update to use this new version to ensure your app is fully compatible with Android 6.0. This will enable you to manage the permission flows appropriately for your app and avoid any potential connection issues. For more details, and a step-by-step guide to what your app should do for the best user experience, take a look at this blog post on the Android Developers site.





App Invites



App Invites allows you to grow your apps audience by letting existing Android and iOS users invite their Google contacts via email or SMS to try your app out. Google Play services 8.1 adds the ability for developers to customize the email invitation, including adding a custom image, and specifying a call-to-action button text. These improvements should help developers increase user engagement and conversions with app invites.



Ambient Mode Maps



Android Wear provides a feature called ambient mode, enabling apps to stay visible, even when they aren’t actively being used. Now, with Google Play services 8.1, the Google Maps Android API supports ambient mode. In this mode, a simplified low-color rendering of the map will be seen. This reduces power consumption by lighting fewer pixels, but the camera and zoom level are retained, so user context will be kept. To learn more about ambient mode, check out this blog post.



Nearby Status Listener



Google Nearby allows you to build simple interactions between nearby devices. A new addition in Google Play services allows your app to receive callbacks when an active Nearby publish or subscribe expires. This frees you from tracking the TTL and allows your app's UI to accurately reflect whether Nearby is active or not.



Play Games Player Stats API



The new Play Games Player Stats API allows you to build better, smarter, games. It will let you tailor user experiences to specific segments of players and different stages of the player lifecycle. For example, you can give your most valuable players that are returning from a break in play a special welcome back message and reward.



Breaking Changes



In this release, there are some changes to GoogleApiClient and PendingResult, making them abstract classes, which may lead to breaking changes in your code. Learn more about these changes and how to handle them in the release notes.







SDK Now available!



You can get started developing today by downloading the Google Play services SDK from the Android SDK Manager. To learn more about Google Play services and the APIs available to you through it, visit our documentation on Google Developers.



Google Play services 8.1 and Android 6.0 Permissions

Posted by, Laurence Moroney, Developer Advocate



Along with new platform features, Android 6.0 Marshmallow has a new permissions model that streamlines the app install and auto-update process. Google Play services 8.1 is the first release to support runtime permissions on devices running Android 6.0. and will obtain all the permissions it needs to support its APIs. As a result, your apps won’t normally need to request permissions to use them. However, if you update your apps to target API level 23, they will still need to check and request runtime permissions, as necessary.



To update your Google Play services apps to handle the latest permissions model, it’s good practice to manage the user’s expectations in setting permissions that the runtime may require. Below are some best practices to help you get started.



Before you begin...



For the purposes of this post, ensure that your API level and Target SDK are set to at least 23. Additionally, ensure that, for backwards compatibility, you are using the V4 support library to verify and request permissions. If you don’t have it already, add it to your gradle file:



 
com.android.support:support-v4:23.0.1


You’ll also need to declare Permissions in your AndroidManifest.xml file. There’s no change here. Whatever permissions your app has always needed should be declared in your AndroidManifest.xml file with the uses-permission tag. Here’s an example:



 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


Documentation on maps and location, including a walkthrough on connecting may be found here.



Step 1. Manage Connections to the GoogleApiClient



Make sure that you are handling connection failures on GoogleApiClient correctly, and that you are using the proper resolution process as outlined here. Note that if Google Play services itself is missing permissions, the user flow to fix them will be handled for you automatically if you follow this methodology.

Here’s an example:



 
@Override
public void onConnectionFailed(ConnectionResult result) {
if (mResolvingError) {
// Already attempting to resolve an error.
return;
} else if (result.hasResolution()) {
try {
mResolvingError = true;
result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
} catch (SendIntentException e) {
// There was an error with the resolution intent. Try again.
mGoogleApiClient.connect();
}
} else {
// Show dialog using GooglePlayServicesUtil.getErrorDialog()
showErrorDialog(result.getErrorCode());
mResolvingError = true;
}
}




Step 2. Verify Permissions before calling APIs



It’s easy to assume that once you can connect, and you’ve declared the required permissions for APIs that you want to use in your AndroidManifest.xml file, that future calls will be fine. However, it is vital to ensure that you have the required permission before calling an API or connecting to the GoogleApiClient. This can be done using the checkSelfPermission method of ActivityCompat, Fragment or ContextCompat.



If the call returns false, i.e. the permissions aren’t granted, you’ll use requestPermissions to request them. The response to this will be returned in a callback which you will see in the next step.



Here’s an example:



 
private static final int REQUEST_CODE_LOCATION = 2;

if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// Request missing location permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_CODE_LOCATION);
} else {
// Location permission has been granted, continue as usual.
Location myLocation =
LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
}


Step 3. Implement the request permission callback.



In step 2, if the permission wasn’t granted by the user, the requestPermissions method was called to ask the user to grant them. The response from the user is captured in the onRequestPermissionsResult callback. You need to implement this, and always check the return values because the request could be denied or cancelled. Note that you might need to request multiple permissions here -- this sample just checks for a single permission -- you may need to check for more.



 
public void onRequestPermissionsResult(int requestCode,
String[] permissions,
int[] grantResults) {
if (requestCode == REQUEST_CODE_LOCATION) {
if(grantResults.length == 1
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// success!
Location myLocation =
LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
} else {
// Permission was denied or request was cancelled
}
}


Step 4. Show permission rationale



If the user has previously denied the permission request, your app should display an additional explanation before requesting the permission again. Indeed, if the permissions are non trivial for the core features of the app, and the user is confused as to why they are needed, it would be recommended to guide them.



In this case, before the call to requestPermissions (step 2, above), you should call shouldShowRequestPermissionRationale, and if it returns true, you should create some UI to display additional context for the permission.



As such your code from Step 2 might look like this:




private static final int REQUEST_CODE_LOCATION = 2;

if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// Check Permissions Now

if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
// Display UI and wait for user interaction
} else {
ActivityCompat.requestPermissions(
this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_CODE_LOCATION);

}
} else {
// permission has been granted, continue as usual
Location myLocation =
LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
}





Note that in this case your user may still deny the permissions, in which case you will need to craft your app so as not to be in a situation where a denied permission affects parts of the app where it shouldn’t. Refer to the best practices section on the Android developer’s site for more details and guidance.



If you’ve built any applications that use Google Play services, I’d recommend that you download the Google Play services 8.1 SDK, and rebuild your applications using it, testing against the most recent versions of Android 6.0, which you can download from the Android Developers site.



Useful resources:



Get started with building for Android 6.0



Android Permissions design guidelines



Google IO 2015 Session on Android M Permissions



Samples for Google Play services 8.1 with coding best practices



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."

Telltale Games share their tips for success on Android TV

Lily Sheringham, Developer Marketing at Google Play



Editor’s note: This is another post in our series featuring tips from developers finding success on Google Play. This week, we’re sharing advice from Telltale Games on how to create a successful game on Android TV. -Ed.



With new Android hardware being released from the likes of Sony, Sharp, and Philips amongst others, Android TV and Google Play can help you bring your game to users right in their living rooms through a big screen experience.





The recent Marshmallow update for Android TV means makes it easier than ever to extend your new or existing games and apps for TV. It's important to understand how your game is presented in the user interface and how it can help users get to the content they want quickly.





Telltale Games is a US-founded game developer and publisher, based in San Francisco, California. They’re well known for the popular series ‘The Walking Dead’ and ‘Game of Thrones‘ which was created in partnership with HBO.




Zac Litton, VP of Technology at Telltale Games, shares his tips for creating and launching your games with Android TV.



Tips for launching successful games on Android TV



  1. Determine the Device for Android TV: Determine what device your game is running on by using the UiModeManager.getCurrentModeType() method. If the device is running in television mode, you can declare what to display as the launch point of the game on the Android TV itself (Configuration). Add the LEANBACK_LAUNCHER filter category to one of your intent-filters to identify your game as being enabled for TV. This is required for your game to be considered a TV app in Google Play.


  2. Touchscreen vs TV: TVs don’t have touch screens so make sure you set the touchscreen required flag to false in the manifest as touch is implicitly true by default on Android. This will help avoid your game getting filtered from the TV Play store right out of the gate. Also, check your permissions, as some imply hardware requirements which you may need to override explicitly.


  3. Use Hardware APIs: Use the package manager which has System Feature API to enable your game to reason about what capabilities it can and should expose. For example, whether to show the user touch screen controls or game controller controls. You can also make your app location aware using the location APIs available in Google Play services to add location awareness with automated location tracking, geofencing, and activity recognition.


  4. Use appropriate controllers: To reach the most users, your app should support a simplified input scheme that doesn’t require a directional pad (D-pad controller). The player needs to be able to use a D-Pad in all aspects of the game—not just controlling core gameplay, but also navigating menus and ads, therefore your Android TV game shouldn’t refer to a touch interface specifically. For example, an Android TV game should not tell a player to "Tap here to continue."


  5. Appear in the right place: Make sure you add an android:isGame attribute to the application element of the manifest and set it to true in order to enable the installed game to show up on the correct launcher row, games.


  6. Provide home screen banners: Provide a home screen banner for each localization supported, especially if you are an international developer. The banner (320 x 180) is the game launch point that appears on the TV home screen on the games row.


  7. Use a TV image for your Store Listing: Be sure you provide at least one TV screen shot on your Store Listing page. Then include a high res icon, feature graphic, promo graphic and TV banner.


  8. Improve visibility through ‘search’ and ‘recommendations’: Android TV uses the Android search interface to retrieve content data from installed apps and games, and deliver search results to the user. Implement a ContentProvider to show instant suggestions to the user, and a SearchManager to deep link your game’s content.


  9. Set appropriate pricing and distribution: Check “Distribute to Android TV” in the relevant section in the Developer Console. This will trigger a review by Google to ensure your game meets the minimum requirements for TV.


  10. Guide the user: Use a tutorial to guide the player into the game mechanics and provide an input reference to the user based on the input control they are using.



With the recently released Android TV codelab and online class from Udacity, you can learn how to convert your existing mobile game into Android TV in just four hours. Find out more about how to build games for Android TV and how you to publish them using familiar tools and processes in Google Play.

New Android Marshmallow sample apps

Posted by Rich Hyndman, Developer Advocate



Three new Android Marshmallow sample applications have gone live this week. As usual they are available directly from the Google Samples repository on GitHub or through the Android Studio samples browser.



Android Direct Share Sample





























Direct Share is a new feature in Android Marshmallow that provides APIs to make sharing more intuitive and quick for users. Direct Share allows users to share content to targets, such as contacts, within other apps. For example, the direct share target might launch an activity in a social network app, which lets the user share content directly to a specific friend in that app.



This sample is a dummy messaging app, and just like any other messaging apps, it receives intents for sharing a plain text. It demonstrates how to show some options directly in the list of share intent candidates. When a user shares some text from another app, this sample app will be listed as an option. Using the Direct Share feature, this app also shows some of contacts directly in the chooser dialog.



To enable Direct Share, apps need to implement a Service extending ChooserTargetService. Override the method onGetChooserTargets() and return a list of Direct Share options.



In your AndroidManifest.xml, add a meta-data tag in your Activity that receives the Intent. Specify android:name as android.service.chooser.chooser_target_service, and point the android:value to the Service.



Android MidiSynth Sample



Android 6.0 introduces new support for MIDI. This sample demonstrates how to use the MIDI API to receive and play MIDI messages coming from an attached input device (MIDI keyboard).



The Android MIDI API (android.media.midi) allows developers to connect a MIDI device to an Android device and process MIDI messages coming from it.



This sample demonstrates some basic features of the MIDI API, such as:

  • Enumeration of currently available devices (including name, vendor, capabilities, etc)

  • Notification when MIDI devices are plugged in or unplugged

  • Receiving and processing MIDI messages


It also contains a simple implementation of an oscillator and note playback.



Android MidiScope Sample



A sample demonstrating how to use the MIDI API to receive and process MIDI signals coming from an attached device.



The Android MIDI API (android.media.midi) allows developers to connect a MIDI device to Android and process MIDI signals coming from it. This sample demonstrates some basic features of the MIDI API, such as enumeration of currently available devices (Information includes name, vendor, capabilities, etc), notification when MIDI devices are plugged in or unplugged, and receiving MIDI signals. This sample simply shows all the received MIDI signals to the screen log and does not play any sound for them.



Check out a sample today and jumpstart your Android Marshmallow development.



Android Developer Story: Domain increases installs by 44% with Material Design and Google Play services

Posted by Lily Sheringham, Google Play team



Australian developer Domain is part of a multi-platform property business, which provides search tools and information for buyers, sellers, renters, investors, and agents across Australia. The Domain Real Estate & Property app was voted a top five lifestyle app in Australia and now has three dedicated Android developers who work closely with their design and UX teams.



Product Manager, Henrique Marassi, and Android Developer, Gary Lo, explain how Domain successfully improved their user rating from 2.8 to 4.1 and increased monthly downloads by 44 percent by adopting Material Design and Play services to create a better user experience.







Learn more about how Domain found success on Google Play:


  • Material Design guidelines: How Material Design helps you create beautiful, engaging apps.

  • Google Play services: Learn more about Google Play services and the APIs available to you through it.

  • Find success on Google Play: Products and best practices to help your grow you business globally on Google Play.

Tap. Pay. Done.

Today, we’re beginning to roll out Android Pay -- the simple and secure way to pay with your Android phone at over one million locations across the US. Android Pay also stores your gift cards, loyalty cards and special offers right on your phone. We’ll be rolling out gradually over the next few days, and this is just the beginning. We will continue to add even more features, banks and store locations in the coming months, making it even easier to pay with your Android phone.

The choice is yours 
Android Pay works with all NFC-enabled Android devices (running KitKat 4.4+), on any mobile carrier, at every tap and pay ready location across the US. Android Pay will support credit and debit cards from the four major payment networks: American Express, Discover, MasterCard and Visa. These cards are issued by many of the most popular US banks and credit unions, including American Express, Bank of America, Discover, Navy Federal Credit Union, PNC, Regions Bank, USAA, and U.S. Bank. Wells Fargo will be available in the next few days, Capital One and Citi are coming soon, and we're adding new banks all the time.


Shop at your favorites 
You can use Android Pay at over one million locations (and counting…) across the US, everywhere tap and pay payments are accepted, including:

Security is at the center of Android Pay 
We know how important it is to keep your personal and financial information secure, so Android Pay is supported by industry standard tokenization. This means your real credit or debit card number isn't sent with your payment. Instead, we’ll use a virtual account number that provides an extra layer of security. As soon as you make a purchase, you’ll see a payment confirmation that shows where a given transaction happened, so it’s easy to catch any suspicious activity. And if your phone is ever lost or stolen, simply use Android Device Manager to instantly lock your device from anywhere, secure it with a new password, or even wipe it clean of your personal information.

We’re just getting started...
Later this year, you’ll also be able to use Android Pay to speed through mobile checkout in your favorite apps. And with select merchants, you'll soon be able to transmit your loyalty cards and special offers with just a tap. We’ll be announcing more Android Pay news soon, and would love to hear your feedback on the Android Pay experience (just select Help > Feedback in the app).

If you’re an existing Google Wallet user, you’ll be able to access Android Pay through an update to your Wallet app. For new users, Android Pay will be available for download on Google Play in the next few days, and will come preinstalled on new NFC-enabled Android phones from AT&T, T-Mobile, and Verizon Wireless.

For updates on Android Pay and other Android news, subscribe to this blog, or follow Android on Twitter and Google+.

Posted by Pali Bhat, Director of Product Management, Android Pay

p.s. Looking to send or receive money right from your phone? Click here to learn more about the new Google Wallet

Update: Citi's availability corrected to rolling out in the coming weeks.