android - Notification vibration, sound when screen is locked -


problem

i'm receiving gcm notifications, when screen locked or turned off vibrations , sounds not working. i've tried add wakelock of gcmlistenerservice there wakeful intent when notification triggered. should make work? missing piece?

edits

  • my vibrations work when screen on , unlocked.
  • i found part of gcmlistenerservice responsible receiving gcm push notifications , looks wakelock getting removed (code below)

bundle var2 = var1.getextras(); var2.remove("message_type"); var2.remove("android.support.content.wakelockid");

code

    uri defaultsounduri = ringtonemanager.getdefaulturi(ringtonemanager.type_notification);      notificationcompat.builder notificationbuilder = new notificationcompat.builder(this)             .setsmallicon(r.drawable.ic_notification_icon)             .setcontenttitle(getstring(r.string.new_notification))             .setcontenttext(body)             .setautocancel(true)             .setsound(defaultsounduri)             .setvibrate(new long[] {1000, 1000, 1000})             .setcolor(contextcompat.getcolor(getapplicationcontext(), r.color.colorprimary))             .setcontentintent(pendingintent);      notificationmanager notificationmanager = (notificationmanager) getsystemservice(context.notification_service);      notification notification = notificationbuilder.build();     notification.defaults |= notification.default_vibrate;     notification.defaults |= notification.default_sound;      powermanager pm = (powermanager) getsystemservice(context.power_service);     powermanager.wakelock wl = pm.newwakelock(powermanager.partial_wake_lock | powermanager.acquire_causes_wakeup, "tag");     wl.acquire(10000);      notificationmanager.notify(0, notification); 

so turns out when notification contains data payload , notification payload android when in lock mode creating notification playload tho you've code custom one.

wakelock not needed - gcmlistenerservice decide on it's own if needed long have <uses-permission android:name="android.permission.wake_lock" />