<?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>Background operation of BLE Library with Android 8 - Howto?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/41491/background-operation-of-ble-library-with-android-8---howto</link><description>I have extended the Template app in nRF Toolbox. When my app runs in the background on an Android 8 (only) device and I try to connect to the peripheral, I get this error when trying to execute startService(service) in BleProfileServiceReadyActivity:</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 05 Aug 2019 09:14:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/41491/background-operation-of-ble-library-with-android-8---howto" /><item><title>RE: Background operation of BLE Library with Android 8 - Howto?</title><link>https://devzone.nordicsemi.com/thread/202359?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2019 09:14:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:839f06e8-9b88-4fc2-905c-cef6f2269bb4</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Acutetech,&lt;/p&gt;
&lt;p&gt;Please make a &lt;strong&gt;new case&lt;/strong&gt; and then refer to this case since this case is over 7 months old.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Martin L.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Background operation of BLE Library with Android 8 - Howto?</title><link>https://devzone.nordicsemi.com/thread/202220?ContentTypeID=1</link><pubDate>Fri, 02 Aug 2019 17:50:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db67e7e7-c0f9-4fca-8e7a-ba6517c3a610</guid><dc:creator>Acutetech</dc:creator><description>&lt;p&gt;I would like to ask about this again...&lt;/p&gt;
&lt;p&gt;To set the context: I am working on a digital health sensor with a BLE interface. The user operates the sensor which collects data and saves it. It then starts advertising and will transfer the data when the sensor and the smart phone are next in radio range. The phone then transfers the reading to the cloud. The user does not need to have his phone when he operates the medical device, and he does not need to fire up an app manually in order to send the data to the cloud.&lt;/p&gt;
&lt;p&gt;I have an experimental Android app that combines Nordic&amp;#39;s Android BLE Library and the &lt;a href="https://altbeacon.github.io/android-beacon-library/"&gt;Android Beacon Library.&lt;/a&gt; I have hacked the Android Beacon Library to listen for my custom 128-bit UUID. This works in Android background mode. When the app detects my BLE custom UUID it fires an event and then I switch over to Nordic&amp;#39;s BLE Library to connect to my device and transfer data. (This is obviously out of scope for the Andorid Beacon Library).&lt;/p&gt;
&lt;p&gt;Clearly my specific use case can can be generalised: it should be possible for any BLE sensor (not just beacons) to send data to a phone that the user sees as &amp;quot;off&amp;quot;.&lt;/p&gt;
&lt;p&gt;Most of the time this works very well. But (a) my hack of the Android Beacon Library is pretty ugly, and (b) sometimes my app does not hear my device advertising and I must reset the phone. This is probably because of (a). Also, (c) the Android Beacon Library contains much more code than my app requires.&lt;/p&gt;
&lt;p&gt;I would much prefer to work with one library and not two. What chance is the that I can get Nordic to work with me on this? The spec is to create an example Android app that listens for a BLE device in background mode, connects to it, transfers data and disconnects. I would work with you on this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Background operation of BLE Library with Android 8 - Howto?</title><link>https://devzone.nordicsemi.com/thread/163657?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 08:02:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bf8ce4e-0d42-4e2e-8cd8-7f04f3714b9c</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Hi, I remember answering to this question long time ago, but the answer must have get lost somewhere... Let&amp;#39;s try again.&lt;/p&gt;
&lt;p&gt;Since Android 8 there are restrictions in background services. A background service will be killed 5 min after the application was closed (went to background). Also, they may not be started using startService() when app is not in foreground. More here:&amp;nbsp;&lt;a href="https://developer.android.com/about/versions/oreo/background"&gt;https://developer.android.com/about/versions/oreo/background&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Template app keeps the service running only when the device is connected. I&amp;#39;d change the service to be a foreground service.&lt;/p&gt;
&lt;p&gt;If you need to scan for a device in foreground, use new method in BluetoothLeScanner with IntentFilter instead of using service at all.&lt;/p&gt;
&lt;p&gt;We don&amp;#39;t have any example like you described, unfortunately. I agree that it is a good idea.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>