我正在开发视频通话 android 应用程序。我现在面临的挑战是在您有来电时实现类似于内置在 Call 应用程序中的 android 的全屏通知。目前,每当我接到电话时,如果手机屏幕关闭,通知就会显示为常规通知,如果手机醒着,则通知显示为常规通知。我希望通知像通话应用程序一样占据全屏。我正在使用 Galaxy S5 来测试它。什么我在这里缺少的是我的代码。提前致谢。
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("screen", "debugScreen");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_NO_USER_ACTION);
Intent callAcceptIntent = new Intent(this, MyReceiver.class);
callAcceptIntent.setAction("com.videochat.CALL_INTENT");
PendingIntent callAcceptPi = PendingIntent.getBroadcast(this,0,callAcceptIntent,0);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.icon)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setTicker("ticker")
.setFullScreenIntent(pendingIntent, true)
.setOngoing(true)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(NotificationCompat.PRIORITY_MAX)
.addAction(R.drawable.icon, "Reject",callAcceptPi);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Run Code Online (Sandbox Code Playgroud)