全屏通知仅显示为“正面向上”

我已经把这个问题的头撞到桌子上了3天了,请告诉我我在哪里偏离了。

当我收到一个传入的VoIP电话时,我正在尝试显示全屏通知,就像PhoneApp一样。 如果用户处于身临其境的状态,我可以向前走。 但是,我只得到一个抬头通知,并没有得到一个全屏。 我需要通知忽略locking屏幕。

这是我在做什么:

String callJson = call.toJson(uber).toString(); uber.requestWakeState(UberVoice.WAKE_STATE_FULL); final Notification.Builder builder = new Notification.Builder(uber); builder.setSmallIcon(R.drawable.switch_notification); if (image != null) { builder.setLargeIcon(image); } builder.setOngoing(true); PendingIntent inCallPendingIntent = PendingIntent.getActivity(uber, 234, UberVoice.createInCallIntent(), 0); builder.setContentIntent(inCallPendingIntent); builder.setContentText(body); builder.setUsesChronometer(false); builder.setContentTitle(title); builder.setCategory(Notification.CATEGORY_CALL); builder.setVisibility(Notification.VISIBILITY_PUBLIC); builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), AudioManager.STREAM_RING); builder.setVibrate(new long[]{500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}); builder.setPriority(Notification.PRIORITY_MAX); builder.setTicker(title); builder.setFullScreenIntent(inCallPendingIntent, true); builder.addAction(R.drawable.hangup_action, "Reject", CallService.getPendingIntent(uber, callJson, CallService.REJECT)); builder.addAction(R.drawable.answer_action, "Answer", CallService.getPendingIntent(uber, callJson, CallService.ANSWER)); NotificationManager notificationManager = (NotificationManager) uber.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = builder.build(); notificationManager.notify(INCOMING_CALL_NOTIFICATION_ID, notification); 

这里是creatCallIntent代码:

 public static Intent createInCallIntent() { Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_USER_ACTION); intent.setClassName("<package>", IncomingCallActivity.class.getName()); return intent; } 

这里是IncomingCallActivity.onCreate()

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; getWindow().addFlags(flags); setContentView(R.layout.activity_incoming_call); 

我已经尝试直接开始这个活动(超级是应用程序参考)

 Intent incomingCallIntent = new Intent(uber, IncomingCallActivity.class); String callJson = call.toJson(uber).toString(); incomingCallIntent.putExtra("call", callJson); incomingCallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); uber.startActivity(incomingCallIntent); 

我究竟做错了什么?

Solutions Collecting From Web of "全屏通知仅显示为“正面向上”"

如果我正确理解你的问题,你忘了在IncomingCallActivity添加标志WindowManager.LayoutParams.FLAG_FULLSCREEN

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FULLSCREEN; getWindow().addFlags(flags); 

屏幕locking时,此组合需要显示活动。 希望能帮助到你。

弄清楚了! 正如我所怀疑的那样,这是愚蠢的。

在我的IncomingCallActivity我有以下的代码

 public void onPause() { super.onPause(); finish(); } 

事实certificate,如何通知显示实际上调用onPause ,因此完成活动。

感谢@JohanShogun试图帮助。