如何在LocationListener中创建通知

时间:2018-12-31 14:09:12

标签: android android-notifications

我尝试在启用gps时发送通知-因此,我创建了一个正在侦听的服务(无论是否启用了提供程序)。当我更改gps状态但未创建通知时,它可以正常工作并做出反应

    @Override
    public void onProviderEnabled(String provider) {
        Log.e(TAG, "GPS switched on ");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (!gpsNoteActiv) {
                gpsNoteActiv = true;
                Notification.Builder nb = gpsNotification.getAndroidChannelNotification("GPS aktiviert", "Ihr GPS Signal ist eventuell unbeabsichtigt aktiviert");
                gpsNotification.getManager().notify(101, nb.build());
            }
        }
    }

我在logcat中收到一些通知,我将在底部发布。.是否有类似的方法可以像我尝试的那样发布通知?

? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.apps.maps/com.google.android.apps.gmm.locationsharing.usr.LocationAvailabilityChecker$LocationProvidersChangedBroadcastReceiver
? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.gms/com.google.android.location.internal.NlpNetworkProviderSettingsUpdateReceiver
? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.broadcastreceiver.external.ExternalCommonBroadcastReceiver
? W/audio_hw_generic: Hardware backing HAL too slow, could only write 0 of 720 frames

0 个答案:

没有答案