com.samsung.android.service.health.tracking

Class HealthTrackerException

  • All Implemented Interfaces:
    Serializable


    public class HealthTrackerException
    extends Exception
    This class provides an error code and an error resolution for a failure of HealthTrackingService.connectService().

      
       private final ConnectionListener connectionListener = new ConnectionListener() {
      
           @Override
           public void onConnectionSuccess() {
               //The connection was succeeded.
           }
      
           @Override
           public void onConnectionEnded() {
               // The connection was ended.
           }
      
           @Override
           public void onConnectionFailed(HealthTrackerException exception) {
               // Check the exception's resolution and resolve it.
               if(exception.hasResolution()) {
                   // Display a proper message to the user and call resolve(). 
                   exception.resolve(Activity.this);
               }
           }
       }
       

    Since:
    1.0.0
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int getErrorCode()
      Gets the connection failure error code.
      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

      • OLD_PLATFORM_VERSION

        public static final int OLD_PLATFORM_VERSION
        The Health Platform version is old.
        The constant value is 1.
        Since:
        1.0.0
        See Also:
        Constant Field Values
    • Method Detail

      • hasResolution

        public boolean hasResolution()
        Checks whether the given error has a resolution.
        Precondition:
        Check the network connection.
        Permission:
        android.permission.INTERNET is required.
        Returns:
        true if the platform provides a resolution for the error. Call resolve(Activity) to process.
        false 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 calling this method.

        Precondition:
        Check the network connection.
        Permission:
        android.permission.INTERNET is required.
        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.
        IllegalStateException - if unable to resolve.
        Since:
        1.0.0