I am planning to develop an application which sends notifications to the car head unit with MirrorLink.
I have installed MirrorLink Test Application and it displays action to generate notifications. But it cannot send a notification to the head unit. (Displays fail message) I went through their developer documents and still couldnt find any proper method to implement notification feature.
I am very much greatefull if someone can show a simple example of showing notifications with MirrorLink or a explanation of how notifications work in MirrorLink. Thanks
Support for notifications on MirrorLink devices is optional, so it's possible that the head unit or phone don't support head-unit-provided notifications. The MirrorLink Client Simulator does, the phone you are using may not.
You can check if the phone supports notifications using getEventMappingManager (in the ICommonAPIService.aidl). If it returns null, it's not supported. Or boolean getNotificationEnabled() in INotificationManager.aidl.
Basically, notifications work in a fairly standard way: You invoke the notification with a prompt, title, icon, and a list of actions (as a bundle). It returns with the index of the selected action.
The Common API Test App code (provided on the MirrorLink developer site) shows an example of invoking the notification: List actionList = Arrays.asList(actionListText.getValue().split(",")); Uri iconUrl = Uri.parse(iconUrlListText.getValue());
List<Bundle> actions = new ArrayList<Bundle>();
for (int i=0;i<actionList.size();i++)
{
Bundle action = new Bundle();
action.putInt(Defs.Action.ACTION_ID, i+1);
action.putString(Defs.Action.ACTION_NAME, actionList.get(i));
action.putBoolean(Defs.Action.LAUNCH_APP, false);
actions.add(action);
}
int response = notificationManager.sendClientNotification(notificationTitle.getValue(), notificationBody.getValue(), iconUrl, actions);
if (response == 0)
{
Toast.makeText(getBaseContext(), "Sending notification failed." , Toast.LENGTH_LONG).show();
}
Could you provide an example of what you are doing?
Note: In general, you can't rely on the Notification system being available in most sessions. So if it's critical to operation, you'll have to have a "back up" solution using the built-in notifications in Android.