Author Archives: Reto Meier

How Google Cloud Messaging handles Doze in Android 6.0 Marshmallow

Posted by, Laurence Moroney, Developer Advocate

Android 6.0 Marshmallow introduces a new power saving feature called ‘Doze’. A device enters Doze when the user leaves it unplugged and stationary for a period of time and with the screen off. When this happens, the system defers application activity to save power. It will periodically and briefly resume normal operations, called an idle maintenance window, in order to perform app syncing and other pending operations.

If your app uses Google Cloud Messaging (GCM), you will need to take into account the following behaviors for users whose devices are in Doze.

GCM has two priority types for messages, called high priority and normal priority. When using high priority, GCM attempts to deliver messages immediately, waking a device in Doze, as needed. With Android Marshmallow, nothing changes here.

However, when using normal priority (the default priority), there are a number of different behaviors when the device is in Doze, including:

  • The most important change is that messages will be batched for devices in Doze. When the device enters its idle maintenance window, the batch of messages will be received.
  • We discard messages whose time_to_live expires while the device is in Doze (including TTL=0).

Despite this, it is recommended that, unless absolutely necessary, you keep your notifications as normal priority ones, as this will minimize battery impact. They will still sync during doze mode as described above, and of course once the device exits Doze.

High priority messages should only be used by applications that need to generate an immediate notification to the end user such as a chat app notification or an incoming phone call.

To learn more about Google Cloud Messaging message priorities, visit the Google Developers 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+.

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

Google Play services 8.1: Get ready for Marshmallow!

Posted by, Magnus Hyytsten, 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.

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.