HealthConnectionErrorResult
overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthconnectionerrorresult java.lang.object com.samsung.android.sdk.healthdata.healthconnectionerrorresult public final class healthconnectionerrorresult extends object this class handles errors raised by connection failure to the health data store. considerations for connection failure a partner app works with samsung health. the partner app can meet the following error cases when it connects to samsung health. connection error description platform_not_installed samsung health is not installed. old_version_platform installed samsung health's version is old. platform_disabled samsung health is disabled. user_agreement_needed the user didn't agree to samsung health's terms & conditions and privacy policies. user_password_needed samsung health is locked by the user password. handling connection exceptions samsung health sdk for android helps you to handle all available error cases with healthconnectionerror when your application connects to the health data store. healthconnectionerror is retrieved in healthdatastore.connectionlistener's event handler and all samsung health's partner applications need to check the health data store's connection error mandatorily. the following example shows how to handle the connection error. public class mainactivity extends activity { private healthdatastore mstore; private healthconnectionerrorresult mconnerror; private static mainactivity minstance = null; @override public void oncreate(bundle savedinstancestate) { // ... mstore = new healthdatastore(this, mconnectionlistener); mstore.connectservice(); } @override public void ondestroy() { mstore.disconnectservice(); // ... } private final healthdatastore.connectionlistener mconnectionlistener = new healthdatastore.connectionlistener() { @override public void onconnected() { // connected } @override public void onconnectionfailed(healthconnectionerrorresult error) { // connection fails showconnectionfailuredialog(error); } @override public void ondisconnected() { // connection is disconnected } }; private void showconnectionfailuredialog(healthconnectionerrorresult error) { alertdialog.builder alert = new alertdialog.builder(this); mconnerror = error; if (mconnerror.hasresolution()) { switch(error.geterrorcode()) { case healthconnectionerrorresult.platform_not_installed: message = "please install samsung health"; break; case healthconnectionerrorresult.old_version_platform: message = "please upgrade samsung health"; break; case healthconnectionerrorresult.platform_disabled: message = "please enable samsung health"; break; case healthconnectionerrorresult.user_agreement_needed: message = "please agree to samsung health policy"; break; default: message = "please make samsung health available"; break; } } else { // in case that the device doesn't support samsung health, // hasresolution() returns false also. alert.setmessage(r.string.msg_conn_not_available); } alert.setpositivebutton(r.string.ok, (dialog, id) -> { if (error.hasresolution()) { error.resolve(mainactivity.this); } }); if (error.hasresolution()) { alert.setnegativebutton("cancel", null); } alert.show(); } } since: 1.0.0 see also: healthdatastore.connectionlistener field summary fields modifier and type field and description static int connection_failure the connection is not established in the health data framework. static int old_version_platform the version of the health data framework is outdated to cooperate with sdk. static int old_version_sdk the sdk's data library version is outdated to cooperate with the samsung health's health data framework. static int platform_disabled the health data framework is disabled. static int platform_not_installed samsung health is not installed. static int platform_signature_failure it fails to check the signature of the health data framework. static int timeout the connection time exceeded the limit. static int unknown unknown error. static int user_agreement_needed the user did not agree to terms and conditions, and privacy policy of samsung health yet. static int user_password_needed the user cancels the password input explicitly on the password pop-up window. method summary all methods instance methods concrete methods modifier and type method and description int geterrorcode() gets the error code of connection failure. boolean hasresolution() checks whether the given error has a resolution. void resolve(activity activity) resolves an error with an activity which is able to get the user's feedback for possible error cases. field detail unknown public static final int unknown unknown error. its constant value is 0. since: 1.0.0 see also: constant field values connection_failure public static final int connection_failure the connection is not established in the health data framework. its constant value is 1. since: 1.0.0 see also: constant field values platform_not_installed public static final int platform_not_installed samsung health is not installed. to resolve it: if your app runs on android 11, check your app manifest whether the "<queries>" element is added. see the app manifest guide. call resolve(android.app.activity). it leads the user to install samsung health on an app seller site. its constant value is 2. since: 1.0.0 see also: resolve(android.app.activity), constant field values old_version_sdk public static final int old_version_sdk the sdk's data library version is outdated to cooperate with the samsung health's health data framework. to resolve it: apply the latest data library to your app. if your app uses the latest data library, create an activity to update to install your latest app. its constant value is 3. since: 1.0.0 see also: constant field values old_version_platform public static final int old_version_platform the version of the health data framework is outdated to cooperate with sdk. to resolve it, call resolve(android.app.activity). it leads the user to install the latest samsung health on an app seller site. its constant value is 4. since: 1.0.0 see also: resolve(android.app.activity), constant field values timeout public static final int timeout the connection time exceeded the limit. its constant value is 5. since: 1.0.0 see also: constant field values platform_disabled public static final int platform_disabled the health data framework is disabled. to resolve it, call resolve(android.app.activity). it leads the user to activate samsung health through the phone's settings. its constant value is 6. since: 1.0.0 see also: resolve(android.app.activity), constant field values user_password_needed public static final int user_password_needed the user cancels the password input explicitly on the password pop-up window. some devices can request a password to protect the user's data. the password for the health data access can be registered in samsung health by the user. then the user can enter the password through the password pop-up window. if the predetermined time passed without the valid password input, timeout occurs. its constant value is 7. since: 1.0.0 see also: constant field values platform_signature_failure public static final int platform_signature_failure it fails to check the signature of the health data framework. its constant value is 8. since: 1.0.0 see also: constant field values user_agreement_needed public static final int user_agreement_needed the user did not agree to terms and conditions, and privacy policy of samsung health yet. the health data framework is not activated before agreement. to resolve it, call reslove. it leads the user to the samsung health's service agreement page. its constant value is 9. since: 1.0.0 see also: resolve(android.app.activity), constant field values method detail geterrorcode public int geterrorcode() gets the error code of connection failure. usually it is called in healthdatastore.connectionlistener.onconnectionfailed(healthconnectionerrorresult). it's required to resolve the error depending on its returned error code. returns: the error code since: 1.0.0 hasresolution public boolean hasresolution() checks whether the given error has a resolution. whether the device supports samsung health the sdk supports marshmallow and above android devices including non-samsung devices. and it works with samsung health. there is no connection issue on most devices but it is not available occasionally depending on the device's specification. this api lets you know whether the device supports samsung health. the returned false involves that the device is not available for samsung health. precondition: check the network connection. permission: android.permission.internet returns: true if the platform provides a resolution for the error. call resolve(activity). false in the following cases: if the device doesn't support samsung health if there is no resolution for the error since: 1.0.0 resolve public void resolve(activity activity) resolves an error with an activity which is able to get the user's feedback for possible error cases. it handles the following errors and operations. show a proper message for each error case in your application before call this method. error operation platform_not_installed linked to the application installation page old_version_platform linked to the application installation page platform_disabled linked to settings of the device to turn on samsung health user_agreement_needed linked to the starting screen of samsung health to get the user's agreement precondition: check the network connection. permission: android.permission.internet parameters: activity - an activity which resolves the error with the user's feedback. usually it's the main activity of your application. throws: illegalargumentexception - if the specified input is null or invalid since: 1.0.0