İstisnaları yakalama ve işleme
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Health Connect, bir sorun olduğunda CRUD işlemleri için standart istisnalar geçerli kılar
karşılaşılır. Uygulamanız bu istisnaların her birini
uygun olmalıdır.
HealthConnectClient
üzerindeki her yöntem, atılabilecek istisnaları listeler.
Genel olarak, uygulamanız aşağıdaki istisnaları işlemelidir:
İstisna |
Açıklama |
Önerilen en iyi uygulama |
SecurityException
| İstekler gerektiğinde
izin verilmez.
| Bunu önlemek için
Health Connect veri türlerinin beyan edilmiş olması
uygulamasını indirin. Ayrıca Health Connect izinlerini de beyan etmeniz gerekir
manifest dosyasında ve etkinliğinizde bulabilirsiniz.
|
IOException
|
disk.
| Bu sorunu yaşamamanız için bazı öneriler:
- Kullanıcı girişlerini yedekleyin.
- Toplu yazma işlemleri sırasında ortaya çıkan sorunları çözebilmelisiniz. Örneğin,
Örneğin, sürecin geçmişte kaldığından emin olun ve
kalan işlemlerdir.
- İstek sorunlarını ele almak için yeniden deneme ve geri alma stratejileri uygulama.
|
IllegalStateException
| Aşağıdaki senaryolardan biri gerçekleşti:
- Health Connect hizmeti kullanılamaz.
- İstek geçerli bir yapı değil. Örneğin,
timeRangeFilter için Instant nesnesinin kullanıldığı periyodik paketler.
| Bir istekte bulunmadan önce girişlerle ilgili olası sorunları giderin.
Tercihen, değişkenlere değer atayın veya bunları özel bir
işlevini kullanarak bunları doğrudan isteklerinizde kullanmak yerine
öğrenebilirsiniz.
|
RemoteException
| İçinde veya iletişim sırasında hatalar oluştu
temel hizmeti sunar.
Örneğin,
uygulamanız belirli bir uid ile bir kaydı silmeye çalışıyor. Ancak,
uygulama, temel hizmette hata olduğunu
öğrendikten sonra
Kayıt mevcut değil.
| Bu sorunu yaşamamanız için bazı öneriler:
- Uygulamanızın veri deposu ile Health Connect arasında düzenli senkronizasyonlar yapın.
- İstek sorunlarını ele almak için yeniden deneme ve geri alma stratejileri uygulama.
|
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-27 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-27 UTC."],[],[],null,["# Catch and handle exceptions\n\nHealth Connect throws standard exceptions for CRUD operations when an issue is\nencountered. Your app should catch and handle each of these exceptions as\nappropriate.\n\nEach method on `HealthConnectClient` lists the exceptions that can be thrown.\nIn general, your app should handle the following exceptions:\n\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| **Exception** | **Description** | **Recommended best practice** |\n|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `SecurityException` | There are issues encountered when the requests require permissions that aren't granted. | To avoid this, make sure that you've [declared use of Health Connect data types](/guide/health-and-fitness/health-connect/develop/frequently-asked-questions#declare-access) for your published app. Also, you must declare Health Connect permissions [in the manifest file](/guide/health-and-fitness/health-connect/develop/get-started#step-3) and [in your activity](/guide/health-and-fitness/health-connect/develop/get-started#step-4). \u003cbr /\u003e \u003cbr /\u003e |\n| `IOException` | There are issues encountered upon reading and writing data from disk. | To avoid this issue, here are some suggestions: \u003cbr /\u003e - Back up any user input. - Be able to handle any issues that occur during bulk write operations. For example, make sure the process moves past the issue and carry out the remaining operations. - Apply retries and backoff strategies to handle request issues. \u003cbr /\u003e |\n| `IllegalStateException` | One of the following scenarios has occurred: \u003cbr /\u003e - The Health Connect service isn't available. - The request isn't a valid construction. For example, an aggregate request in periodic buckets where an `Instant` object is used for the `timeRangeFilter`. \u003cbr /\u003e | Handle possible issues with the inputs first before doing a request. Preferably, assign values to variables or use them as parameters within a custom function instead of using them directly in your requests so that you can apply error handling strategies. |\n| `RemoteException` | Errors have occurred within, or in communicating with, the underlying service to which the SDK connects. For example, your app is trying to delete a record with a given `uid`. However, the exception is thrown after the app finds out upon checking in the underlying service that the record doesn't exist. | To avoid this issue, here are some suggestions: \u003cbr /\u003e - Perform regular syncs between your app's datastore and Health Connect. - Apply retries and backoff strategies to handle request issues. \u003cbr /\u003e |\n\n\u003cbr /\u003e"]]