<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>BLE App background connection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63405/ble-app-background-connection</link><description>Hi, 
 My devices are currently using NRF52832 with SDK17.0.0. 
 I want to communicate with my devices even when the app is killed by the Android system. 
 At this moment, when I close the phone after some time, the connection no longer exist. 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 07 Jul 2020 08:22:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63405/ble-app-background-connection" /><item><title>RE: BLE App background connection</title><link>https://devzone.nordicsemi.com/thread/258743?ContentTypeID=1</link><pubDate>Tue, 07 Jul 2020 08:22:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d74f511-e40e-478f-89f8-d7839af328bf</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There&amp;#39;s something called background service limitations in&amp;nbsp;Android 8+.&amp;nbsp;&amp;nbsp;Service needs to be promoted to foreground service, which displays a notification, to not be killed after 5 min.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;However, there&amp;#39;s a new API in Bluetooth Le Scanner which allows to scan using PendingIntent.&amp;nbsp;So you may register in the system that your app should be awakened when some device is found.&amp;nbsp;And connect to it, in foreground service if the constant connection is needed.&amp;nbsp;This scan with pending intent can be started, as you said, on broadcast receiver for this event.&amp;nbsp;When using Scanner Compat library for Android it will try to emulate this pending intent on earlier os versions.&amp;nbsp;Using the background scanner, this will of course use much more battery.&amp;nbsp;So it can be done efficiently on Android 8+.&amp;nbsp; You can search on the internet about&amp;nbsp;&lt;span&gt;Bluetooth Le Scanner.&amp;nbsp;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; The support staff is reduced during the summer holidays, and you may experience delayed answers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>