문제 내 화면이 잠금 또는 해제 후 내 진동과 소리가 작동하지 않습니다 켜져 그러나알림 진동 화면이 잠겨 소리
내가 GCM 알림을 수신하고 있습니다. wakelock을 추가하려고 시도했지만 GCMListenerService의 모양으로 알림이 트리거 될 때 이미 깨어있는 의도가 있습니다. 작동하게하려면 어떻게해야합니까? 누락 된 부분은 어디 있습니까?
편집 화면이 켜져 있고 잠금 해제 할 때 내 진동이 작동
- .
- 나는 GCM 푸시 알림을 수신 할 책임이
GcmListenerService
의 일부를 발견하고 가동 잠금이 제거지고처럼 (아래 코드)
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);
<uses-permission android:name="android.permission.WAKE_LOCK" />
당신이'추가했다 가지고 필요한 경우 <사용 - 권한 안드로이드 : 이름 = "android.permission.VIBRATE"/>' –@Logic yes, 물론 – JakubW