Skip to content

07.Notification and Message

Kilnn edited this page Jun 30, 2023 · 19 revisions

Notification

Use FcMessageFeature.sendNotification to send a message notification to the device.

You can send a variety of different message notifications, such as QQ, WeChat, Facebook, etc. But at first, you should use FcDeviceInfo.isSupportNotification to ensure this type is supported. And ensure that the type is enabled in FcNotificationConfig.

The configuration items in FcNotificationConfig are not one-to-one corresponding to the message types in FcNotificationType. This is because there are three types of notifications for telephony types: incoming calls, answering and hanging up.

Because Android does not support ANCS, so these notification messages need to be captured by yourself. Like monitor phone rings and hangs up, listen to the SMS. Other third-party notifications such as QQ, WeChat messages, etc., consider using NotificationListenerService to capture.

Message

The device may send various messages to the phone, and use FcMessageFeature.observerMessage to listen for these messages.

The message type define in FcMessageType

Find phone

When receiving FcMessageType.FINE_PHONE type message indicating that the device is finding for the phone.

Usually, after receiving this message on your phone, you need to make a ring or vibration to respond to the device's finding. And when you start responding, you need to send FcMessageFeature.replayFindPhone.

After the finding starts, both parties can actively stop the finding process. Listen FcMessageType.STOP_FINE_PHONE message to stop phone finding, and send FcMessageFeature.stopFindPhone to stop device finding.

Find device

Use FcMessageFeature.findDevice to find device.

Camera control

When receiving FcMessageType.CAMERA_WAKE_UP message, app should launch a Camera activity.

When receiving FcMessageType.CAMERA_EXIT message, app should exit Camera activity.

And you should also use FcMessageFeature.setCameraStatus to send you camera statue to device.

Media control

Use FcMessageFeature.observerMessage to listen for the following messages to for media control

  • FcMessageType.MEDIA_PLAY_PAUSE
  • FcMessageType.MEDIA_NEXT
  • FcMessageType.MEDIA_PREVIOUS
  • FcMessageType.MEDIA_VOLUME_UP
  • FcMessageType.MEDIA_VOLUME_DOWN
  • FcMessageType.MEDIA_SILENT_MODE

You can use FcBuiltInFeatures.mediaControl without having to handle the message yourself.

Music control

When receiving FcMessageType.MUSIC_STATE and FcMessageType.MUSIC_INFO messages, you should use FcMessageFeature.setMusicState and FcMessageFeature.setMusicInfo to send music state/info to device.

You can use FcBuiltInFeatures.musicControl without having to handle the message yourself. But this feature relies on NotificationListenerService, you need to use FcConnector.musicControlNotificationListenerService to pass in this instance. The FitCloud SDK util class AbsNotificationListenerService implemented this function.

Clone this wiki locally