Android

BLE on Android

BLE is the Wireless communication where very less energy is consumed compared to standard Bluetooth Classic. Like other mobile platforms Android natively supports it.

I started working on BLE commnunication using healthcare devices like Weight Scale, BP Monitor, Glucose meter and Pulse oximeter. The problem I had to solve was to improve this communication where users were facing a lot of issues pairing/syncing these peripherals with Android phone running our app. Having very brief documentation about BLE low level APIs on Android, handling the asynchronous communication, resolving errors was not an easy task. We ought to have written a layer of abstraction on top of these APIs which would handle command queues, threading and managing connection. But then we found this Library Blessed which helped us solve all these issues and communicate better with BLE peripherals on Android.

3 min read

Applinks on Android 12

If you are trying to access your app from web, trying to click on a link which automatically opens the app without ambiguity, you need app links to be created. Before Android 12 (API 31), adding intent filters under the Activity which needs to open on link clicking would open the app, may be with some amibguity. But if targetSdk is set to 31, there are mandatory steps need to be followed, otherwise the link can open only on the browser.

Follow the step from Android documentation here and here

Things to note here:

  • If you are using multple domains ensure that all the domains have hosted correct assetlinks.json.
  • If verification of under one domain fails, then entire verification fails.

    Note: On Android 11 (API level 30) and lower, the system establishes your app as the default handler for the specified URL patterns only if it finds a matching Digital Asset Links file for all hosts in the manifest.

  • Install the app through adb, or run the following command, open logcat and see the verification process working.
$ adb shell pm verify-app-links --re-verify <PACKAGE_NAME>

Filter with IntentFilterIntentOp

I/IntentFilterIntentOp: Verification 23 complete. Success:true. Failed hosts:. [CONTEXT service_id=244 ]
  • Make sure the sha256_cert_fingerprints are correct. sha256_cert_fingerprints of debug & release keystore are different. If only release fingerprints are added on assetlinks.json, the verification doesn’t work on debug version. so adb shell pm get-app-links returns legacy_failure. It will work if both fingerprints are added(debug & release) on assetlinks.json

  • Ensure there are no syntax errors or unnecessary spaces or special characters added to assetlinks.json It is better to use App Links Assistant tool provided by Android Studio to create this file instead of manually creating. For testing the assetlinks.json statements are correct, use this

If verifying manually, the typical output expected:

$ adb shell pm get-app-links --user cur
 com.example
  com.example:
    ID: 90a79cb0-b63c-4ffa-aeb7-b3ad109a7272
    Signatures: [ED:64:B4:70:53:31:7E:C0:F4:99:9B:F9:49:AA:D1:0F:1D:63:75:B1:CB:03:DD:5D:D7:BC:E3:E2:7D:2E:00:29]
    Domain verification state:
      api.prod.example.com: legacy_failure
      api.test.example.com: legacy_failure
      api.dev.example.com: legacy_failure
    User 0:
      Verification link handling allowed: true
      Selection state:
        Disabled:
          api.prod.example.com
          api.test.example.com
          api.dev.example.com
$ adb shell pm set-app-links --package com.example 0 all
$ adb shell pm get-app-links --user cur
 com.example
  com.example:
    ID: 90a79cb0-b63c-4ffa-aeb7-b3ad109a7272
    Signatures: [ED:64:B4:70:53:31:7E:C0:F4:99:9B:F9:49:AA:D1:0F:1D:63:75:B1:CB:03:DD:5D:D7:BC:E3:E2:7D:2E:00:29]
    Domain verification state:
      api.prod.example.com: none
      api.test.example.com: none
      api.dev.example.com: none
    User 0:
      Verification link handling allowed: true
      Selection state:
        Disabled:
          api.prod.example.com
          api.test.example.com
          api.dev.example.com
		  

Give some time for it to complete the verification process

$ adb shell pm get-app-links –user cur com.example com.example: ID: 4f4f913e-c4be-4b03-b782-9d6b9233396f Signatures: [ED:64:B4:70:53:31:7E:C0:F4:99:9B:F9:49:AA:D1:0F:1D:63:75:B1:CB:03:DD:5D:D7:BC:E3:E2:7D:2E:00:29] Domain verification state: api.prod.example.com: verified api.test.example.com: verified api.dev.example.com: verified User 0: Verification link handling allowed: true Selection state: Disabled: api.prod.example.com api.test.example.com api.dev.example.com

I have spent hours debugging applinks which failed to open the app, instead it would try it on browser on Android 12. There are some blog posts around this which helped me troubleshooting.

https://zarah.dev/2022/02/08/android12-deeplinks.html https://handstandsam.com/2017/07/11/troubleshooting-auto-verification-of-seamless-android-app-deep-linking/

With the above steps followed, it will also resolve the ambiguity on older OS versions, open the exact intended app.

2 min read

Accessibility on Android: make apps accessible to all the users

Screen Reader:

  • When Screen Reader is turned on, on Android devices, it automatically announces what element is in focus.

  • It is recommended to use views that Android provides which include view’s role and content required by Accessibility service. If you need a custom button, you extend the Button rather than starting from scratch with a View.

1 min read

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read
Back to Top ↑

targetSdk

Applinks on Android 12

If you are trying to access your app from web, trying to click on a link which automatically opens the app without ambiguity, you need app links to be created. Before Android 12 (API 31), adding intent filters under the Activity which needs to open on link clicking would open the app, may be with some amibguity. But if targetSdk is set to 31, there are mandatory steps need to be followed, otherwise the link can open only on the browser.

Follow the step from Android documentation here and here

Things to note here:

  • If you are using multple domains ensure that all the domains have hosted correct assetlinks.json.
  • If verification of under one domain fails, then entire verification fails.

    Note: On Android 11 (API level 30) and lower, the system establishes your app as the default handler for the specified URL patterns only if it finds a matching Digital Asset Links file for all hosts in the manifest.

  • Install the app through adb, or run the following command, open logcat and see the verification process working.
$ adb shell pm verify-app-links --re-verify <PACKAGE_NAME>

Filter with IntentFilterIntentOp

I/IntentFilterIntentOp: Verification 23 complete. Success:true. Failed hosts:. [CONTEXT service_id=244 ]
  • Make sure the sha256_cert_fingerprints are correct. sha256_cert_fingerprints of debug & release keystore are different. If only release fingerprints are added on assetlinks.json, the verification doesn’t work on debug version. so adb shell pm get-app-links returns legacy_failure. It will work if both fingerprints are added(debug & release) on assetlinks.json

  • Ensure there are no syntax errors or unnecessary spaces or special characters added to assetlinks.json It is better to use App Links Assistant tool provided by Android Studio to create this file instead of manually creating. For testing the assetlinks.json statements are correct, use this

If verifying manually, the typical output expected:

$ adb shell pm get-app-links --user cur
 com.example
  com.example:
    ID: 90a79cb0-b63c-4ffa-aeb7-b3ad109a7272
    Signatures: [ED:64:B4:70:53:31:7E:C0:F4:99:9B:F9:49:AA:D1:0F:1D:63:75:B1:CB:03:DD:5D:D7:BC:E3:E2:7D:2E:00:29]
    Domain verification state:
      api.prod.example.com: legacy_failure
      api.test.example.com: legacy_failure
      api.dev.example.com: legacy_failure
    User 0:
      Verification link handling allowed: true
      Selection state:
        Disabled:
          api.prod.example.com
          api.test.example.com
          api.dev.example.com
$ adb shell pm set-app-links --package com.example 0 all
$ adb shell pm get-app-links --user cur
 com.example
  com.example:
    ID: 90a79cb0-b63c-4ffa-aeb7-b3ad109a7272
    Signatures: [ED:64:B4:70:53:31:7E:C0:F4:99:9B:F9:49:AA:D1:0F:1D:63:75:B1:CB:03:DD:5D:D7:BC:E3:E2:7D:2E:00:29]
    Domain verification state:
      api.prod.example.com: none
      api.test.example.com: none
      api.dev.example.com: none
    User 0:
      Verification link handling allowed: true
      Selection state:
        Disabled:
          api.prod.example.com
          api.test.example.com
          api.dev.example.com
		  

Give some time for it to complete the verification process

$ adb shell pm get-app-links –user cur com.example com.example: ID: 4f4f913e-c4be-4b03-b782-9d6b9233396f Signatures: [ED:64:B4:70:53:31:7E:C0:F4:99:9B:F9:49:AA:D1:0F:1D:63:75:B1:CB:03:DD:5D:D7:BC:E3:E2:7D:2E:00:29] Domain verification state: api.prod.example.com: verified api.test.example.com: verified api.dev.example.com: verified User 0: Verification link handling allowed: true Selection state: Disabled: api.prod.example.com api.test.example.com api.dev.example.com

I have spent hours debugging applinks which failed to open the app, instead it would try it on browser on Android 12. There are some blog posts around this which helped me troubleshooting.

https://zarah.dev/2022/02/08/android12-deeplinks.html https://handstandsam.com/2017/07/11/troubleshooting-auto-verification-of-seamless-android-app-deep-linking/

With the above steps followed, it will also resolve the ambiguity on older OS versions, open the exact intended app.

2 min read

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

Bluetooth

BLE on Android

BLE is the Wireless communication where very less energy is consumed compared to standard Bluetooth Classic. Like other mobile platforms Android natively supports it.

I started working on BLE commnunication using healthcare devices like Weight Scale, BP Monitor, Glucose meter and Pulse oximeter. The problem I had to solve was to improve this communication where users were facing a lot of issues pairing/syncing these peripherals with Android phone running our app. Having very brief documentation about BLE low level APIs on Android, handling the asynchronous communication, resolving errors was not an easy task. We ought to have written a layer of abstraction on top of these APIs which would handle command queues, threading and managing connection. But then we found this Library Blessed which helped us solve all these issues and communicate better with BLE peripherals on Android.

3 min read

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

BLE

BLE on Android

BLE is the Wireless communication where very less energy is consumed compared to standard Bluetooth Classic. Like other mobile platforms Android natively supports it.

I started working on BLE commnunication using healthcare devices like Weight Scale, BP Monitor, Glucose meter and Pulse oximeter. The problem I had to solve was to improve this communication where users were facing a lot of issues pairing/syncing these peripherals with Android phone running our app. Having very brief documentation about BLE low level APIs on Android, handling the asynchronous communication, resolving errors was not an easy task. We ought to have written a layer of abstraction on top of these APIs which would handle command queues, threading and managing connection. But then we found this Library Blessed which helped us solve all these issues and communicate better with BLE peripherals on Android.

3 min read

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

Android12

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

run-time

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

permissions

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

location

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

fine_location_permission

Bluetooth Permissions on Android 12

Beginning with Android 12, new run-time permissions are added for accessing nearby Bluetooth devices. Without this permission any APIs related to Bluetooth devices access will result into Fatal Exception:

1 min read
Back to Top ↑

Date

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read
Back to Top ↑

Joda-time

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read
Back to Top ↑

Java8

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read
Back to Top ↑

java.time

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read
Back to Top ↑

sugar

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read
Back to Top ↑

desugar

Then Joda, Now Java 8 APIs

Why Joda?

I had to implement a feature in our app which would trigger repeat alarms which will be set based on specific events. Our project minSdk was set to 23 (Yes, we support Android 6!) and I thought Java 8 Time APIs I cannot use. So Joda was the option I had.

4 min read
Back to Top ↑

accessibility

Accessibility on Android: make apps accessible to all the users

Screen Reader:

  • When Screen Reader is turned on, on Android devices, it automatically announces what element is in focus.

  • It is recommended to use views that Android provides which include view’s role and content required by Accessibility service. If you need a custom button, you extend the Button rather than starting from scratch with a View.

1 min read
Back to Top ↑

contentDescription

Accessibility on Android: make apps accessible to all the users

Screen Reader:

  • When Screen Reader is turned on, on Android devices, it automatically announces what element is in focus.

  • It is recommended to use views that Android provides which include view’s role and content required by Accessibility service. If you need a custom button, you extend the Button rather than starting from scratch with a View.

1 min read
Back to Top ↑

ScreenReader

Accessibility on Android: make apps accessible to all the users

Screen Reader:

  • When Screen Reader is turned on, on Android devices, it automatically announces what element is in focus.

  • It is recommended to use views that Android provides which include view’s role and content required by Accessibility service. If you need a custom button, you extend the Button rather than starting from scratch with a View.

1 min read
Back to Top ↑

TalkBack

Accessibility on Android: make apps accessible to all the users

Screen Reader:

  • When Screen Reader is turned on, on Android devices, it automatically announces what element is in focus.

  • It is recommended to use views that Android provides which include view’s role and content required by Accessibility service. If you need a custom button, you extend the Button rather than starting from scratch with a View.

1 min read
Back to Top ↑