Class PermissionHandler

java.lang.Object
com.flir.thermalsdk.androidsdk.helpers.PermissionHandler

public class PermissionHandler extends Object
Encapsulated the asking of permission in Android, the class has to be used by an Activity.
Support handling both permissions for Network, Bluetooth.
The Activity registered with this utility class has to implement "onRequestPermissionsResult(..)" and call this handlers "onRequestPermissionsResult(..)"
Note that you also need to describe the permissions required in Android manifest.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PermissionHandler(@NotNull android.app.Activity parentActivity)
    Creates a permission handler/helper to request or check runtime permissions.
    PermissionHandler(@NotNull android.app.Activity parentActivity, @Nullable ShowMessage showMessage)
    Creates a permission handler/helper to request or check runtime permissions.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    checkAndRequestPermissionGroup(String[] permissions, int requestCode)
    Check if we have permissions, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
    static void
    checkBluetoothScanPermissions(@NotNull android.content.Context context)
    Check if the application has all required runtime permissions to perform discovery over Bluetooth classic or Bluetooth Low Energy (BLE).
    static void
    checkWifiAutoConnectPermissions(@NotNull android.content.Context context)
    Check if the application has all required runtime permissions to perform WiFi network auto connect and switch.
    static void
    checkWifiDiscoveryPermissions(@NotNull android.content.Context context)
    Check if the application has all required runtime permissions to perform discovery over WiFi network.
    boolean
    onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
    Handles the information from a request Permission dialog, usually to be called by the associated PermissionHandler Activity eg:
    Activity:onRequestPermissionsResult(...) { permissionHandler.onRequestPermissionsResult(...); }
    boolean
    requestBluetoothPermission(int requestCode, boolean requireConnectionToDevice)
    Check if we have all permissions required to work with Bluetooth/BLE, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
    boolean
    requestCameraPermission(int requestCode)
    Check if the application has all required runtime permissions to access camera resource, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
    boolean
    requestF1EdgeProPermission(int requestCode)
    Check if we have all permissions required to work with FLIR ONE Edge Pro, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
    boolean
    requestNetworkPermission(int requestCode)
    Check if we have Network permission, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PermissionHandler

      public PermissionHandler(@NotNull @NotNull android.app.Activity parentActivity)
      Creates a permission handler/helper to request or check runtime permissions.
      Parameters:
      parentActivity - activity that requests the permissions
    • PermissionHandler

      public PermissionHandler(@NotNull @NotNull android.app.Activity parentActivity, @Nullable @Nullable ShowMessage showMessage)
      Creates a permission handler/helper to request or check runtime permissions.
      Parameters:
      showMessage - optional instance used as a callback with info messages
      parentActivity - activity that requests the permissions
  • Method Details

    • checkWifiDiscoveryPermissions

      public static void checkWifiDiscoveryPermissions(@NotNull @NotNull android.content.Context context)
      Check if the application has all required runtime permissions to perform discovery over WiFi network.
      Throws:
      SecurityException - if the application is missing any of the required permission
    • checkWifiAutoConnectPermissions

      public static void checkWifiAutoConnectPermissions(@NotNull @NotNull android.content.Context context)
      Check if the application has all required runtime permissions to perform WiFi network auto connect and switch.
      Throws:
      SecurityException - if the application is missing any of the required permission
    • checkBluetoothScanPermissions

      public static void checkBluetoothScanPermissions(@NotNull @NotNull android.content.Context context)
      Check if the application has all required runtime permissions to perform discovery over Bluetooth classic or Bluetooth Low Energy (BLE).
      Throws:
      SecurityException - if the application is missing any of the required permission
    • requestNetworkPermission

      public boolean requestNetworkPermission(int requestCode)
      Check if we have Network permission, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
      Parameters:
      requestCode - a request code used to read back the permission results - you can use any value for a request code, but keep in mind that we can only use lower 8 bits for requestCode (so this value must be less than 0xFF)
      Returns:
      true if all permissions were given otherwise false and show a dialog requesting the permission
    • requestCameraPermission

      public boolean requestCameraPermission(int requestCode)
      Check if the application has all required runtime permissions to access camera resource, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
      Parameters:
      requestCode - a request code used to read back the permission results - you can use any value for a request code, but keep in mind that we can only use lower 8 bits for requestCode (so this value must be less than 0xFF)
      Returns:
      true if all permissions were given otherwise false and show a dialog requesting the permission
    • requestF1EdgeProPermission

      public boolean requestF1EdgeProPermission(int requestCode)
      Check if we have all permissions required to work with FLIR ONE Edge Pro, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
      Parameters:
      requestCode - a request code used to read back the permission results - you can use any value for a request code, but keep in mind that we can only use lower 8 bits for requestCode (so this value must be less than 0xFF)
      Returns:
      true if all permissions were granted otherwise false
    • requestBluetoothPermission

      public boolean requestBluetoothPermission(int requestCode, boolean requireConnectionToDevice)
      Check if we have all permissions required to work with Bluetooth/BLE, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
      Parameters:
      requestCode - a request code used to read back the permission results - you can use any value for a request code, but keep in mind that we can only use lower 8 bits for requestCode (so this value must be less than 0xFF)
      requireConnectionToDevice - a flag defining if we need intent to connect to the Bluetooth/BLE device (if so an additional permission will be check and eventually requested)
    • onRequestPermissionsResult

      public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
      Handles the information from a request Permission dialog, usually to be called by the associated PermissionHandler Activity eg:
      Activity:onRequestPermissionsResult(...) { permissionHandler.onRequestPermissionsResult(...); }
      Returns:
      true if all requested permissions were granted otherwise false
    • checkAndRequestPermissionGroup

      public boolean checkAndRequestPermissionGroup(String[] permissions, int requestCode)
      Check if we have permissions, if not it shows a dialog requesting the permission and "onRequestPermissionsResult(..)" is called with the result.
      Returns:
      true if all permissions were given otherwise return false and show a dialog requesting the permission