ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

Improve User Engagement using Cross Device Experiences on Android

Photo by The Average Tech Guy on Unsplash

According to parks associates research announced at CES 2024, the average American has about 17 connected devices in their household. This could be a Tablet, Watch, Smart speakers, TVs and AR headsets with their connected phones.

As technology advances, we can anticipate a rise in the number of smart devices capable of communicating with each other.

These represent expanded opportunities for app developers and organizations to build a cohesive user experience for their consumers.

Historically, app developers had to cross different hurdles for managing different network stacks, authentication, privacy etc. across devices, which can increase the cost of investing in cross device experiences.

Fortunately now there are tools and technologies that are available for applications on platforms that developers can leverage to advance their app capabilities for building cross-device experiences and ambient computing.

Building cross device experiences does not only result in better user experience for the end-user but also can immensely help with increasing the app engagement metrics. The examples of these features could be users transferring a call from your Phone device to another Phone or Tablet, or sending a notification from TV to your Phone, or perhaps transferring media from your Phone to Watch. The potential for these cross device user journeys is endless.

So, how can app developers develop the cross device functionalities? Specifically, talking about Android there are libraries that Google offers that can be utilized for this.

Cross-device SDK

Cross-device SDK allows users to build cross device experiences that can span multiple devices. This allows app developers ie. the users of the SDK to not worry about internals of the communication, whether the exchange is taking place over Bluetooth, BLE, WiFi or other network technologies, delivering best cross device experience to the end users.

It does offer multiple APIs for Device Discovery, Secure Communication & Multidevice Sessions.

For example application can access the Device Discovery API as following

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
devicePickerLauncher = Discovery.create(this).registerForResult(this, handleDevices);
}

After getting registering the devicePickerLauncher, this can be then used to launch the device picker dialog

devicePickerLauncher.launchDevicePickerFuture(
/*DeviceFilter=*/ Collections.emptyList(),
new StartComponentRequest.Builder()
.setAction("com.example.crossdeviceaction")
.setReason("Demo")
.addExtra("Key", "value")
.build());

Once Cross device SDK establish connection to the devices and the user picks the device from the device picker list, the users are asked for a confirmation on the receiving device to launch the app which when accepted launches the specific activity with action.

The receiving activity can retrieve the sender device (participant) like the following

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Participant participant = Discovery.create(this).getParticipantFromIntent(getIntent());
}

API reference docs for discovery and other APIs can be also found here -https://developer.android.com/reference/com/google/ambient/crossdevice/discovery

Nearby Connections

Nearby Connections API which enables seamless nearby interactions, available for Android and iOS, and enables communication between the two platforms. This can provide value for user experiences with devices in close proximity to each other.

For Nearby Connections, applications have to handle their advertisement and discovery lifecycles.

Before we look at the APIs, we have to understand two terms here

Advertisement are beacons that are sent by devices if they want to be scanned during the discovery. Generally, this is done over Bluetooth or BLE.

Discovery is active scanning of devices that are nearby, which are often actively advertising for it.

Applications can advertise using this API

Nearby.getConnectionsClient(appContext).startAdvertising()

and can discover devices that advertising using this API

Nearby.getConnectionsClient(appContext).startDiscovery()

Applications when integrating to Nearby Connections API have to manage their own advertising and discovery cycles.

After discovery of devices, the discoverer can request a connection using this API

Nearby.getConnectionsClient(appContext).requestConnection()

After the discoverer has requested a connection to an advertiser, both sides are notified of the connection initiation process via the onConnectionInitiated() method of the ConnectionLifecycleCallback callback. This contains authentication tokens as well, which applications can use to authenticate the connection.

API reference docs for NearbyConnection APIs can be found here https://developers.google.com/android/reference/com/google/android/gms/nearby/connection/package-summary

Google Cast SDK

The Google Cast SDK is useful if your app has video content which allows extending Android (or iOS, or Web) applications to direct its streaming video and audio to a TV or sound system. Apps then becomes the remote control to play, pause, seek, rewind, stop, and otherwise control the media.

It allows building experiences for two different scenarios

1. An end-to-end Cast-based solution. In this scenario, the developer must build both the Sender app and two Receiver apps: an Android TV Receiver and a Web Receiver (more on this below).

2. A Cast-enabled Sender app that can cast content (a screen or a multimedia stream) to Google’s default Cast Receiver, which is called the Default Media Receiver. In this scenario, the developer only needs to build one app, the Sender. The Default Media Receiver is useful for learning and very limited playback scenarios. It is not practical for receivers that require custom business logic, credentials, rights management, or analytics.

Sender could be applications running on Android, iOS or Web and the receivers are on Web (needed) or Android (recommended).

More documentation on the cast APIs can be found here - https://developers.google.com/android/reference/com/google/android/gms/cast/package-summary.

Firebase Cloud Messaging

Another example of cross device service is FCM (Firebase Cloud Messaging) which can be used to send notifications from the client to the app server and notifications from the server to the client. This is useful for experiences involving devices that have connectivity to the internet. Firebase and FCM is a more understood concept amongst Android developers.

These services are available for anyone to use from Google Play Services on Android devices.

In conclusion, building cross device journeys is never easier than before and developers can utilize this to bring more users to their apps, providing a much richer and better integrated user experience for their applications.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response