{"id":1922,"date":"2017-08-22T14:33:18","date_gmt":"2017-08-22T14:33:18","guid":{"rendered":"https:\/\/www.beaconzone.co.uk\/blog\/?p=1922"},"modified":"2024-10-20T13:45:16","modified_gmt":"2024-10-20T13:45:16","slug":"bluetooth-scanning-on-android-oreo","status":"publish","type":"post","link":"https:\/\/www.beaconzone.co.uk\/blog\/bluetooth-scanning-on-android-oreo\/","title":{"rendered":"Bluetooth Scanning on Android Oreo"},"content":{"rendered":"\n<p>Successive Android versions have become increasingly strict on what goes on in background in order to save battery power. The usual way of scanning for beacons on Android is to have an Android <a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Service.html\" target=\"_blank\" rel=\"noopener noreferrer\">Service<\/a> that uses the Bluetooth API to scan for beacons every n seconds. From Android Oreo (8.0), this is no longer reliable as the OS has <a href=\"https:\/\/developer.android.com\/about\/versions\/o\/background.html\" target=\"_blank\" rel=\"noopener noreferrer\">background limitations<\/a> that kill the Service soon after the app UI has gone from the foreground.<\/p>\n\n\n\n<p>Apps now have to use the BluetoothManager <a href=\"https:\/\/developer.android.com\/reference\/android\/bluetooth\/le\/BluetoothLeScanner.html\" target=\"_blank\" rel=\"noopener noreferrer\">BluetoothLEScanner<\/a>&nbsp;call that sets up a <a href=\"https:\/\/developer.android.com\/reference\/android\/bluetooth\/le\/BluetoothLeScanner.html#startScan(java.util.List<android.bluetooth.le.ScanFilter>, android.bluetooth.le.ScanSettings, android.app.PendingIntent)&#8221; target=&#8221;_blank&#8221; rel=&#8221;noopener noreferrer&#8221;>callbackIntent<\/a> that fires when beacons are seen.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>&#8220;The scan results will be delivered via the PendingIntent. Use this method of scanning if your process is not always running and it should be started when scan results are available.&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p>Apps that target multiple Android versions need to support both the old and new mechanisms which complicates development (and support).<\/p>\n\n\n\n<p>We offer <a href=\"https:\/\/beaconzone.consulting\/\" target=\"_blank\" rel=\"noreferrer noopener\">development services<\/a> should you need any further advice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Successive Android versions have become increasingly strict on what goes on in background in order to save battery power. The usual way of scanning for beacons on Android is to have an Android Service that uses the Bluetooth API to scan for beacons every n seconds. From Android Oreo (8.0), this is no longer reliable &hellip; <a href=\"https:\/\/www.beaconzone.co.uk\/blog\/bluetooth-scanning-on-android-oreo\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bluetooth Scanning on Android Oreo&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"_links":{"self":[{"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1922"}],"collection":[{"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=1922"}],"version-history":[{"count":6,"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1922\/revisions"}],"predecessor-version":[{"id":9594,"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1922\/revisions\/9594"}],"wp:attachment":[{"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=1922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=1922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beaconzone.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=1922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}