קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
ב-Android מגרסה 12.0 (רמת API 31) ואילך, המערכת מספקת את
תבנית התראות CallStyle כדי להבדיל בין התראות על שיחות לבין התראות על שיחות
סוגים אחרים של התראות. השתמשו בתבנית זו כדי ליצור הודעות נכנסות או
התראות על שיחות פעילות. התבנית תומכת בהתראות בפורמט גדול
שכוללות את פרטי המתקשר/ת ופעולות נדרשות כמו מענה
דחיית השיחות.
השיחות הנכנסות והמתמשכות הן אירועים בעדיפות גבוהה, ולכן ההתראות האלה
לקבל עדיפות עליונה בלוח ההתראות. הדירוג הזה מאפשר גם
כדי להעביר את השיחות המועדפות האלה למכשירים אחרים.
תבנית ההתראות של CallStyle כוללת את הפעולות הנדרשות הבאות:
מענה או דחייה של שיחות נכנסות.
ניתוק בשיחות יוצאות.
מענה או ניתוק לסינון שיחות.
פעולות בסגנון הזה מופיעות כלחצנים והמערכת מוסיפה אוטומטית
של הסמלים והטקסטים המתאימים. אין תמיכה בתיוג ידני של הלחצנים.
למידע נוסף על העקרונות לעיצוב התראות:
התראות.
איור 1. תבנית CallStyle לשיחות נכנסות ומתמשכות.
הפעולות הנדרשות מועברות ככוונות, כמו hangupIntent ו
answerIntent בסעיפים הבאים. כל אחד מהם הוא הפניה
מתוחזקת על ידי המערכת. האסימון הוא אובייקט קל
יכולה לעבור בין אפליקציות ותהליכים שונים. המערכת
האחראי על ניהול משך החיים של האסימון, וכן לוודא
אפשר להשתמש ב-PendingIntent גם אם האפליקציה שיצרה אותו כבר לא
ריצה. כשנותנים לאפליקציה אחרת PendingIntent, מקבלים
לו את ההרשאה לבצע את הפעולה שצוינה, כמו דחייה או תשובה.
ההרשאה הזו מוענקת גם אם האפליקציה שיצרה את ה-Intent
לא פועל כרגע. למידע נוסף, עיינו במשאבי העזרה
עבור PendingIntent.
לפניכם דוגמאות לשימוש בשיטות שונות עם CallStyle
התראה.
Kotlin
// Create a new call, setting the user as the caller.valincomingCaller=Person.Builder().setName("Jane Doe").setImportant(true).build()
Java
// Create a new call with the user as the caller.PersonincomingCaller=newPerson.Builder().setName("Jane Doe").setImportant(true).build();
שיחה נכנסת
משתמשים בשיטה forIncomingCall() כדי ליצור התראה על סגנון שיחה עבור
שיחה נכנסת.
Kotlin
// Create a call style notification for an incoming call.valbuilder=Notification.Builder(context,CHANNEL_ID).setContentIntent(contentIntent).setSmallIcon(smallIcon).setStyle(Notification.CallStyle.forIncomingCall(caller,declineIntent,answerIntent)).addPerson(incomingCaller)
Java
// Create a call style notification for an incoming call.Notification.Builderbuilder=Notification.Builder(context,CHANNEL_ID).setContentIntent(contentIntent).setSmallIcon(smallIcon).setStyle(Notification.CallStyle.forIncomingCall(caller,declineIntent,answerIntent)).addPerson(incomingCaller);
שיחה פעילה
משתמשים בשיטה forOngoingCall() כדי ליצור התראה על סגנון שיחה עבור
שיחה פעילה.
Kotlin
// Create a call style notification for an ongoing call.valbuilder=Notification.Builder(context,CHANNEL_ID).setContentIntent(contentIntent).setSmallIcon(smallIcon).setStyle(Notification.CallStyle.forOngoingCall(caller,hangupIntent)).addPerson(second_caller)
Java
// Create a call style notification for an ongoing call.Notification.Builderbuilder=newNotification.Builder(context,CHANNEL_ID).setContentIntent(contentIntent).setSmallIcon(smallIcon).setStyle(Notification.CallStyle.forOngoingCall(caller,hangupIntent)).addPerson(second_caller);
סינון שיחה
משתמשים בשיטה forScreeningCall() כדי ליצור התראות לגבי סגנון שיחה
סינון שיחה.
Kotlin
// Create a call style notification for screening a call.valbuilder=Notification.Builder(context,CHANNEL_ID).setContentIntent(contentIntent).setSmallIcon(smallIcon).setStyle(Notification.CallStyle.forScreeningCall(caller,hangupIntent,answerIntent)).addPerson(second_caller)
Java
// Create a call style notification for screening a call.Notification.Builderbuilder=newNotification.Builder(context,CHANNEL_ID).setContentIntent(contentIntent).setSmallIcon(smallIcon).setStyle(Notification.CallStyle.forScreeningCall(caller,hangupIntent,answerIntent)).addPerson(second_caller);
תאימות לגרסאות Android נוספות
שיוך ההתראות של CallStyle בגרסאות API 30 או גרסאות קודמות אל
שירות שפועל בחזית כדי להקצות להם את הדירוג הגבוה שניתן להם ב-API
רמה 31 ואילך. בנוסף, התראות של CallStyle לגבי גרסה 30 של API
או לפני כן יכולים להשיג דירוג דומה על ידי סימון ההתראה בתור
צבעוניים, באמצעות השיטה setColorized().
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],null,["# Create a call style notification for call apps\n\nOn Android 12.0 (API level 31) and later, the system provides the\n[`CallStyle`](/reference/android/app/Notification.CallStyle) notification template to distinguish call notifications from\nother types of notifications. Use this template to create incoming or\nongoing call notifications. The template supports large-format notifications\nthat include caller information and required actions such as answering or\ndeclining calls.\n\nBecause incoming and ongoing calls are high priority events, these notifications\nreceive top priority in the notification shade. This ranking also enables the\nsystem to forward these prioritized calls to other devices.\n\nThe `CallStyle` notification template includes the following required actions:\n\n- **Answer** or **Decline** for incoming calls.\n- **Hang up** for ongoing calls.\n- **Answer** or **Hang up** for call screening.\n\nActions in this style appear as buttons, with the system automatically adding\nappropriate icons and text. Manual labeling of the buttons is not supported.\nFor more information about notification design principles, see\n[Notifications](/design/ui/mobile/guides/home-screen/notifications).\n**Figure 1.** CallStyle template for incoming and ongoing calls.\n\nThe required actions are passed as intents, such as `hangupIntent` and\n`answerIntent` in the following sections. Each of these are a reference to a\ntoken maintained by the system. The token is a lightweight object that\ncan be passed between different apps and processes. The system is\nresponsible for managing the lifetime of the token and ensuring that the\n`PendingIntent` is usable even if the app that created it is no longer\nrunning. When you give another app a `PendingIntent`, you are granting\nit the permission to perform the operation specified, such as decline or answer.\nThis permission is granted even if the app that created the intent\nis not currently running. For more information, see the reference documentation\nfor [`PendingIntent`](/reference/android/app/PendingIntent).\n\nStarting in Android 14 (API level 34), you can configure call notifications\nto be non-dismissible. To do so, use `CallStyle` notifications with the\n[`Notification.FLAG_ONGOING_EVENT`](/reference/android/app/Notification#FLAG_ONGOING_EVENT) through\n[`Notification.Builder#setOngoing(true)`](/reference/android/app/Notification.Builder#setOngoing(boolean)).\n\nThe following are examples of using various methods with the `CallStyle`\nnotification. \n\n### Kotlin\n\n```kotlin\n// Create a new call, setting the user as the caller.\nval incomingCaller = Person.Builder()\n .setName(\"Jane Doe\")\n .setImportant(true)\n .build()\n```\n\n### Java\n\n```java\n// Create a new call with the user as the caller.\nPerson incomingCaller = new Person.Builder()\n .setName(\"Jane Doe\")\n .setImportant(true)\n .build();\n```\n\nIncoming call\n-------------\n\nUse the `forIncomingCall()` method to create a call style notification for an\nincoming call. \n\n### Kotlin\n\n```kotlin\n// Create a call style notification for an incoming call.\nval builder = Notification.Builder(context, CHANNEL_ID)\n .setContentIntent(contentIntent)\n .setSmallIcon(smallIcon)\n .setStyle(\n Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent))\n .addPerson(incomingCaller)\n```\n\n### Java\n\n```java\n// Create a call style notification for an incoming call.\nNotification.Builder builder = Notification.Builder(context, CHANNEL_ID)\n .setContentIntent(contentIntent)\n .setSmallIcon(smallIcon)\n .setStyle(\n Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent))\n .addPerson(incomingCaller);\n```\n\nOngoing call\n------------\n\nUse the `forOngoingCall()` method to create a call style notification for an\nongoing call. \n\n### Kotlin\n\n```kotlin\n// Create a call style notification for an ongoing call.\nval builder = Notification.Builder(context, CHANNEL_ID)\n .setContentIntent(contentIntent)\n .setSmallIcon(smallIcon)\n .setStyle(\n Notification.CallStyle.forOngoingCall(caller, hangupIntent))\n .addPerson(second_caller)\n```\n\n### Java\n\n```java\n// Create a call style notification for an ongoing call.\nNotification.Builder builder = new Notification.Builder(context, CHANNEL_ID)\n .setContentIntent(contentIntent)\n .setSmallIcon(smallIcon)\n .setStyle(\n Notification.CallStyle.forOngoingCall(caller, hangupIntent))\n .addPerson(second_caller);\n```\n\nScreen a call\n-------------\n\nUse the `forScreeningCall()` method to create a call style notification for\nscreening a call. \n\n### Kotlin\n\n```kotlin\n// Create a call style notification for screening a call.\nval builder = Notification.Builder(context, CHANNEL_ID)\n .setContentIntent(contentIntent)\n .setSmallIcon(smallIcon)\n .setStyle(\n Notification.CallStyle.forScreeningCall(caller, hangupIntent, answerIntent))\n .addPerson(second_caller)\n```\n\n### Java\n\n```java\n// Create a call style notification for screening a call.\nNotification.Builder builder = new Notification.Builder(context, CHANNEL_ID)\n .setContentIntent(contentIntent)\n .setSmallIcon(smallIcon)\n .setStyle(\n Notification.CallStyle.forScreeningCall(caller, hangupIntent, answerIntent))\n .addPerson(second_caller);\n```\n\nProvide compatibility across more Android versions\n--------------------------------------------------\n\nAssociate `CallStyle` notifications on API versions 30 or earlier with a\nforeground service in order to assign them the high rank they are given in API\nlevel 31 or later. Additionally, `CallStyle` notifications on API version 30\nor earlier can achieve a similar ranking by marking the notification as\ncolorized, using the [`setColorized()`](/reference/android/app/Notification.Builder#setColorized(boolean)) method.\n\nUse the Telecom APIs with `CallStyle` notifications. For more information, see\n[Telecom framework overview](/guide/topics/connectivity/telecom)."]]