banner 728x90

Integrate BlackBerry CPaaS with Android Auto: secure apps for cars

banner 728x90

1x1.trans - Integrate BlackBerry CPaaS with Android Auto: secure apps for cars


In the past few months you've probably heard a lot about the unrivaled software from BlackBerry being rolled out in the latest fleet of connected cars & autonomous vehicles. The & # 39; sickest whips & # 39; at CES, QNX contain embedded software systems in conceptual designs for the future, including the Aston Martin DB11 and Range Rover Supercharged. This month, a leader in software security for the automotive industry, BlackBerry CEO John Chen delivered a speech at the world-famous Detroit Auto Show. It is clear that BlackBerry is preparing the way for the automotive future.

How to Build BlackBerry Secure Apps for Cars

With the BlackBerry CPaaS (BBM Enterprise SDK) you can easily embed secure voice, video and messages in your application and extend this functionality for use on Android Auto. This is an essential service for companies with employees in the field, who need safer access to their work applications on the road. Fire brigades, ambulances, police, delivery services and a number of specialized vehicles can all benefit from their work applications that are available on their car display and their communications secured by BlackBerry CPaaS. This article tells you how to extend an existing sample application for use on Android Auto, where you can send and receive messages on your Android Auto display or desktop emulator.


Only two requirements are required to build and demonstrate this highly secure Android Auto application:

  1. Build first the RichChat & # 39; application that comes with the free download of the BBM Enterprise SDK. This will serve as a starting point for this tutorial. View our BlackBerry Youtube channel for a quick start guide to RichChat.
  2. To test the application, you must have a car display with Android Auto or simply install the car radio unit on your desktop. For information on how to set up the emulator for testing, see the official Building Apps for Auto documentation.

Configure the manifest for Android Auto Support

Let's start! First we have to let the Android system know that our app is now compatible with Android Auto screens. In the RichChat example, we do this by declaring support for Android Auto Messaging in our app manifest.

Explanation for Android Auto support in AndroidManifest.xml:

. . .

. . .

The above statement refers to an extra XML file that we will add to our project. This file will let the Android system know what kind of service we want to offer to Auto via our application. For this example, we simply want to provide messaging and notification services for Android Auto.

Create the file automotive_app_desc.xml in the res / xml folder of your project with the following statement:


Next, we explain our read and reply broadcast receivers in the manifest of the app. This allows the Android Auto framework to recognize actions (intents objects) of our user. Things like playing the audio for a text message and answering a message with voice commands are handled through these recipients. For our example, this can be done by including the following statements in AndroidManifest.xml:

Statement for read and reply recipient:

 . . . 

. . .

This initial configuration is standard for all Android Auto applications that support messages. More information on integrating messaging services for Android Auto can be found in the official guide.

Expand the NotificationItem interface with the chat ID of the conversation

For simplicity, we are extending the NotificationItem interface into to include a method to get the chat ID directly from a NotificationItem chat. This can be done very easily by adding ~ 3 lines of code as follows:

In, add an explanation for the getChatId () method in the NotificationItem interface:

 public interface NotificationItem  

In, define the getChatId () method for the ChatMessageNotificationItem class (this class implements the NotificationItem interface):

public String getChatId ()  

Create the read and answer BroadcastReceivers

Create a new folder in your project for your Android Auto read and reply recipients (the folder path should look like … / richchat / auto). Then create two new Java classes in this new folder, one for the read receiver and one for the answer receiver:

1x1.trans - Integrate BlackBerry CPaaS with Android Auto: secure apps for cars

Define the newly created read receiver:

This class defines the behavior that occurs when a user listens to a message in Android Auto. For our application we mark the message as & # 39; read & # 39; with the ChatMessageRead API in the BBM Enterprise SDK. See the comments in the code below for more information.

Add the following code to the newly created MessageReadReceiver class:

 public class MessageReadReceiver expands BroadcastReceiver {
private static final String  TAG  = MessageReadReceiver.class.getSimpleName ();

private static final String  CONVERSATION_ID  = "conversation_id";

// This observer marks the read messages when they are played for the user on Android Auto
private Observer mMarkMessagesReadObserver;

@ Override
public void onReceive (Context context, Intent intent) 

 / **
* Mark all messages in the chat as read
* /
 private void markMessageAsRead (final String chatId) {
final ObservableValue  obsChat = BBMEnterprise.  getInstance  (). getBbmdsProtocol (). getChat (chatId);
mMarkMessagesReadObserver = new Observer () ;
// Add the chatObserver to the chat
obsChat.addObserver (mMarkMessagesReadObserver);
// Execute the modified method
mMarkMessagesReadObserver.changed ();

Define the newly created Answer Receiver:

When the user replies to a message, Android Auto sends back an intent to the application and calls the reply recipient to handle the action. For our application we want to send the answer to the conversation to which it belongs. This is done via the ChatMessageSend API in the BBM Enterprise SDK. See the remarks in the code below for more information

 public class MessageReplyReceiver extends BroadcastReceiver  

Expand the notifications of your app with the CarExtender

First add the following constants to the BBMNotificationManager class:

 public static final String  SEND_MESSAGE_ACTION  =
public static final String  READ_ACTION  =
public static final String  REPLY_ACTION  =
public static final String  CONVERSATION_ID  = "conversation_id";
public static final String  EXTRA_VOICE_REPLY  = "extra_voice_reply"; 

Next, we will add two methods to create our intentions for reading and response actions, to report the Android auto framework to share these actions with the user when they occur.

Add the following two methods to the BBMNotificationManager:

 // Creates an intention that is activated when a message is read.
private Intent getMessageReadIntent (String conversationId) 

// Creates an intention that is activated when a speech word is received.
private Intent getMessageReplyIntent (String conversationId)  

Finally, we will extend notifications for some messages that are activated in the post () method of the BBMNotificationManager class with support for Android Auto.

Add the following code to the post () method in file:

 public void post (Boolean silent) 


And that's all! Connect to your Android Auto display or emulator and try it out! You will now receive notifications from the RichChat app and can reply with your voice.

RichChat on Android Auto in action:

1x1.trans - Integrate BlackBerry CPaaS with Android Auto: secure apps for cars

For the sake of simplicity, this sample plays the most recent message received in the chat and marks the entire conversation as read when listening to that message. In a production environment, the app would play the unread messages in order and use the ChatMessage.messageId to mark the messages in the chat to this message as & # 39; read & # 39 ;.

Thank you for reading! Go to the BBM Enterprise SDK developer portal for more information about the BBM Enterprise SDK.

1x1.trans - Integrate BlackBerry CPaaS with Android Auto: secure apps for cars

About Jeff J.

As part of the Enterprise Solutions Team, I am working to bring the latest BlackBerry software and security features to life on the Android platform.

banner 728x90
    Resetting of file changes with git
    Resetting of file changes with git
    There are many different philosophies when it
    DDoS protection by Incapsula (sponsored)
    DDoS protection by Incapsula (sponsored)
    DDoS security is an incredibly important protection
    Long e-mail discussions: Be Gone !!
    Long e-mail discussions: Be Gone !!
    We've all been working on those long
    Changes to permissions for AWS Mobile Hub
    Changes to permissions for AWS Mobile Hub
    Until recently, when you first created an

    Leave a reply "Integrate BlackBerry CPaaS with Android Auto: secure apps for cars"

    Must read×