בדיקת הפונקציונליות של Health Connect
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בדף הזה מתוארות הפונקציות העיקריות של Health Connect API.
פעולות CRUD ברשומה וסנכרון נתונים
הפלטפורמה מספקת פונקציות סטנדרטיות להוספה, לעדכון ולמחיקה של נתונים שתועדו. Health Connect כולל גם פונקציונליות שמאפשרת לאפליקציות לקוח לסנכרן נתונים מ-Health Connect. כך נוצר יומן של שינויים בנתונים, שמראה למפתחים ולמשתמשים אם סוגי נתונים מסוימים הוכנסו או נמחקו על ידי אפליקציות אחרות.
פונקציות צבירה בסיסיות
לקוחות יכולים להחיל פונקציית צבירת נתונים על הנתונים הבסיסיים, ולקבל את הנתונים הבאים:
- הערכים הממוצעים, המינימליים או המקסימליים (לדוגמה, הדופק המינימלי והמקסימלי במהלך סשן פעילות).
- הסכום הכולל (לדוגמה, מספר הצעדים הכולל במרווח זמן יומי).
- ספירה פשוטה של מספר המדידות הבסיסיות (לדוגמה, מספר סשני הפעילות בשבוע נתון).
- משך הזמן הכולל בסוגים נתמכים של נתונים (לדוגמה, הזמן שבילתם בשינה עמוקה השבוע או משך הזמן הכולל של סשני הפעילות היום).
בדיקות זמינות
אפליקציית Health Connect תואמת ל-Android SDK מגרסה 28 (Pie) ואילך.
ה-SDK מאפשר לאפליקציות לקוח לקבוע אם Health Connect API נמצא במכשיר Android של המשתמש. אם לא, מערכת Health Connect מפעילה בדיקת זמינות כדי לקבוע אם המכשיר של המשתמש תואם.
בדיקות הרשאות
כדי להשתמש ב-Health Connect, עליכם לבקש מהמשתמשים הרשאה לקרוא ולכתוב את נתוני הבריאות והכושר שלהם בכל אפליקציה בנפרד. היא גם מאפשרת לראות אילו הרשאות המשתמש כבר העניק או דחה.
קריאה באמצעות Health Connect
קריאה בחזית
בדרך כלל אפשר לקרוא נתונים מ-Health Connect כשהאפליקציה נמצאת בחזית. במקרים כאלה, מומלץ להשתמש בשירות שפועל בחזית כדי להריץ את הפעולה הזו, למקרה שהמשתמש או המערכת יעבירו את האפליקציה לרקע במהלך פעולת קריאה.
במצבים שבהם יכולה להיות הפרעה באפליקציה, למשל הצגת קריאה באפליקציה, כדאי לקרוא ישירות מ-Health Connect לאפליקציית הלקוח.
במצבים שבהם אתם מעדיפים שהאפליקציה תפעל ללא הפרעות, כדאי להשתמש בשירות שפועל בחזית:
FOREGROUND_SERVICE_TYPE_HEALTH
: ההרשאה הזו מאפשרת לאפליקציה להישאר בחזית כדי לאסוף נתוני חיישנים, למשל אפליקציית אימון שממשיכה לאסוף נתונים גם כשהמשתמש מעביר את האפליקציה לרקע.
FOREGROUND_SERVICE_TYPE_SHORT_SERVICE
: שירות גנרי שמאפשר לאפליקציה להמשיך לאסוף נתונים קריטיים למשימות שנמשכות פחות משלוש דקות, גם אם המשתמש מעביר את האפליקציה לרקע לפני שהיא מסתיימת.
קריאה ברקע
אתם יכולים לבקש שהאפליקציה תפעל ברקע ותקריא נתונים מ-Health Connect. אם מבקשים את ההרשאה קריאה ברקע, המשתמש יכול להעניק לאפליקציה גישה לקריאת נתונים ברקע.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. 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,["# Review Health Connect functionality\n\nThis page describes the main functions of the Health Connect API.\n\nCRUD operations on record and data synchronization\n--------------------------------------------------\n\nThe platform provides standard insert, update, and delete functions for recorded\ndata. Health Connect also includes functionality that allows client apps to\nsynchronize data out of Health Connect. This produces a log of data changes\nthat shows the developer and user whether certain data types have been\ninserted or deleted by other apps.\n\nBasic aggregation functions\n---------------------------\n\nClients can apply an aggregation function over underlying data, providing the\nfollowing:\n\n- The **average, minimum or maximum** values (for example, the minimum and maximum heart rate during an activity session).\n- The **sum total** (for example, the total step count in a daily interval).\n- A **simple count** of the number of underlying measurements (for example, the number of activity sessions in a given week).\n- The **total duration** on supported data types (for example, time spent in deep sleep this week, or total duration of activity sessions today).\n\nAvailability checks\n-------------------\n\nHealth Connect is compatible with Android SDK version 28 (Pie) and higher.\nThe SDK allows client apps to determine whether the Health Connect API is on\nthe user's Android-powered device. If it isn't, Health Connect triggers an\navailability check to determine whether the user's device is compatible.\n\nPermission checks\n-----------------\n\nHealth Connect requires you to request the user's permission to read and\nwrite their health and fitness data on a per-app basis. It also lets you\nsee what permissions have already been granted or denied by the user.\n\nReading with Health Connect\n---------------------------\n\n### Foreground reading\n\nYou can normally read data from Health Connect when your app is\nin the foreground. In these cases, you may consider using a foreground service\nto run this operation in case the user or system places your app\nin the background during a read operation.\n\nFor situations in which your app may expect an interruption, such as displaying\na reading in your application, read directly from Health Connect to your client\napplication.\n\nFor situations in which you prefer your app to run without\ninterruptions, use a\n[foreground service](/develop/background-work/services/fgs):\n\n- [`FOREGROUND_SERVICE_TYPE_HEALTH`](/reference/android/content/pm/ServiceInfo#FOREGROUND_SERVICE_TYPE_HEALTH): Allows app to remain in\n the foreground to collect sensor data, such as a workout app that continues\n to collect data even when the user puts the app in the background.\n\n- [`FOREGROUND_SERVICE_TYPE_SHORT_SERVICE`](/reference/android/content/pm/ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE): A generic-type\n service that allows an app to continue to collect critical data for\n tasks that take less than three minutes,\n even if the user places the app in the background before it completes.\n\n### Background reading\n\nYou can request that your application run in the background and read data from\nHealth Connect. If you request the\n[Background Read](/health-and-fitness/guides/health-connect/develop/read-data#background-read-example)\npermission, your user can grant your app access to read data in the background."]]