如何在android中显示时间敏感的通知

如何在android中显示时间敏感的通知,android,android-notifications,android-10.0,Android,Android Notifications,Android 10.0,在android Q中限制从后台启动活动后,我正在尝试使用developer.android示例代码为我的VOIP呼叫生成通知,但它不起作用。你能帮我解决这个问题吗 下面的代码是我用来构建时间敏感通知的示例: Intent fullScreenIntent = new Intent(this, CallActivity.class); PendingIntent fullScreenPendingIntent = PendingIntent.getAc

在android Q中限制从后台启动活动后,我正在尝试使用developer.android示例代码为我的VOIP呼叫生成通知,但它不起作用。你能帮我解决这个问题吗

下面的代码是我用来构建时间敏感通知的示例:

  Intent fullScreenIntent = new Intent(this, CallActivity.class);
                    PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, 0,
                            fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);

                    NotificationCompat.Builder notificationBuilder =
                            new NotificationCompat.Builder(this, CHANNEL_ID)
                                    .setSmallIcon(R.drawable.notification_icon)
                                    .setContentTitle("Incoming call")
                                    .setContentText("(919) 555-1234")
                                    .setPriority(NotificationCompat.PRIORITY_HIGH)
                                    .setCategory(NotificationCompat.CATEGORY_CALL)
                                    .setFullScreenIntent(fullScreenPendingIntent, true);

                    Notification incomingCallNotification = notificationBuilder.build();

由于您使用的是Android 10,因此需要请求
USE\u FULL\u SCREEN\u INTENT
权限。在您的
AndroidManifest.xml
中:

<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />


请参阅:

由于您使用的是Android 10,因此需要请求
使用全屏\u意图
权限。在您的
AndroidManifest.xml
中:

<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />


请参阅:

哇,它是开箱即用的。我用过这根线。从后台服务调用后。如果不工作,你可以设置正在进行(真)。哇,它是开箱即用的。我用过这根线。从后台服务调用后。如果不工作,您可以设置Continuous(true)。您可以帮助startForeground(notificationId,notification);我不确定startForeground的定义在哪里。您能帮助我定义startForeground(notificationId,notification);我不确定startForeground的定义在哪里