-
Notifications
You must be signed in to change notification settings - Fork 32
07.Notification and Message
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.
The device may send various messages to the phone, and use FcMessageFeature.observerMessage to listen for these messages.
The message type define in FcMessageType
sample project: Refer to
FindPhoneManager.kt
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.
sample project: Refer to
OtherFeaturesFragment.kt
Use FcMessageFeature.findDevice to find device.
sample project: Refer to
CameraActivity.kt
Use FcMessageFeature.observerMessage to listen the camera message:
- FcMessageType.CAMERA_WAKE_UP: Launch your camera activity
- FcMessageType.CAMERA_EXIT: Exit your camera activity
- FcMessageType.CAMERA_TAKE_PHOTO: Take photo in your camera activity.
Use FcMessageFeature.setCameraStatus to send you camera status to device. Such as setCameraStatus(true) on activity resume, setCameraStatus(false) on activity pause.
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.
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.