小编San*_*dav的帖子

Android推送通知声音仅在应用处于前景时播放,但在应用处于后台时不播放声音

我在下面的代码中使用FCM进行推送通知,以便在收到通知时播放声音

 public void playNotificationSound() {
        try {

            Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            Ringtone r = RingtoneManager.getRingtone(mContext, notification);
            r.play();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我正在调用这个OnMessageReceived方法,但声音仅在应用处于前景时播放,而不是在应用处于后台时播放

 @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.e(TAG, "From: " + remoteMessage.getFrom());

        if (remoteMessage == null)
            return;

        // Check if message contains a notification payload.
        if (remoteMessage.getNotification() != null) {
            Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
            handleNotification(remoteMessage.getNotification().getBody());
        }

        // Check if message contains a data payload.
        if (remoteMessage.getData().size() > 0) {
            Log.e(TAG, "Data Payload: " …
Run Code Online (Sandbox Code Playgroud)

android push-notification android-notifications firebase firebase-notifications

12
推荐指数
3
解决办法
1万
查看次数

如何在谷歌地图上绘制折线,两个位置之间有两种不同的颜色

我有两个位置,我需要在这两个位置之间绘制两条折线,我完成了在这些位置之间绘制折线.

问题是,折线是一种颜色,但由于要求我必须绘制两种不同颜色的折线,如下所示: - 在此输入图像描述

如果有人有一些有意义的代码片段或对此问题的一些建议...在此先感谢

android google-maps polyline google-polyline

6
推荐指数
1
解决办法
2733
查看次数

如何在Android应用程序中启用谷歌地图导航

我在谷歌地图上有两个点,第一个是源,第二个是目的地,我在地图上的这些点之间有路线.现在我想要将用户从源到目的地导航,就像Google在谷歌地图上所做的那样: - 在此输入图像描述

android google-maps google-maps-android-api-2 google-maps-urls

6
推荐指数
1
解决办法
8070
查看次数