<?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>Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52570/android-ble-library-development</link><description>Hi: 
 We has a device use the hid keyboard and privacy gatt Service. Now we development the app with Android-BLE-Library, and can not to resolve some question. 
 1. While get the remote device name with call BluetoothDevice.getName(), the library return</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Oct 2019 09:48:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52570/android-ble-library-development" /><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/214322?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 09:48:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c92f984e-7904-44bb-b477-97459eb028b7</guid><dc:creator>sam</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&amp;nbsp;Aleksander:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; The Service is connected and response the communication from remote device (nRF52832) automatically. So, app should be listen the bluetooth open and close. And the app will listen the SMS,&amp;nbsp; Incoming call&amp;nbsp;use the broadcast receiver.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks！&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sam&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/214297?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 08:53:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71b85b33-729a-41f3-8bf2-4f6278ddaf81</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Hi, i&amp;#39;m on vacations now but I can ask someone to help you. Also, as i wrote above, you can&amp;#39;t bind to a service that runs in a different process. You have to stay it using `startService(...)` method. Why do you need to have the service running in another process, if I may ask?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/214291?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 08:33:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4a560c5-63f6-4ab1-a6b2-ed7d0513e7a3</guid><dc:creator>sam</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&amp;nbsp;Aleksander:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; I am sure the service is running&amp;nbsp;on background after bind to it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; Under file is the project test code. Can you resolve it, let the&amp;nbsp;broadcast receiver work?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks!&lt;br /&gt;Sam&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/My-Application.zip"&gt;devzone.nordicsemi.com/.../My-Application.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/214258?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 05:11:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6d6b489-e962-4583-9f56-8014551366b9</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;I think you can use the service with a broadcast receiver on such service, but remember that using services run ning in another thread is very tricky. You can&amp;#39;t bind to them, you have to send data using handlers and messages, like between 2 different apps. Are you sure your service is created and started? Also, a service running on background may be killed quite quickly on newer Android versions. Check out background thread executions on Android.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/214255?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 03:44:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b706d37-e5c5-4155-910b-f86c2df0d11b</guid><dc:creator>sam</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&amp;nbsp;Aleksander:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; I am try the HID device enable automatically.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; And , another question, the&amp;nbsp;BroadcastReceiver is not work any more after set the Service to Remote .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;Can i use&amp;nbsp;the BroadcastReceiver&amp;nbsp;in here?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sam&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;
&amp;lt;manifest xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;
    xmlns:dist=&amp;quot;http://schemas.android.com/apk/distribution&amp;quot;
    package=&amp;quot;com.hyperspace.smartwatch&amp;quot;&amp;gt;

    &amp;lt;uses-permission android:name=&amp;quot;android.permission.BLUETOOTH&amp;quot; /&amp;gt;
    &amp;lt;uses-permission android:name=&amp;quot;android.permission.BLUETOOTH_ADMIN&amp;quot; /&amp;gt;


    &amp;lt;application
        android:allowBackup=&amp;quot;true&amp;quot;
        android:icon=&amp;quot;@mipmap/ic_launcher&amp;quot;
        android:label=&amp;quot;@string/app_name&amp;quot;
        android:roundIcon=&amp;quot;@mipmap/ic_launcher_round&amp;quot;
        android:supportsRtl=&amp;quot;true&amp;quot;
        android:theme=&amp;quot;@style/AppTheme&amp;quot;&amp;gt;

        &amp;lt;service
            android:name=&amp;quot;.service.BluetoothManageService&amp;quot;
            android:process=&amp;quot;:Remote&amp;quot;
            android:enabled=&amp;quot;true&amp;quot;
            android:exported=&amp;quot;true&amp;quot;/&amp;gt;

        &amp;lt;activity
            android:name=&amp;quot;.MainActivity&amp;quot;
            android:label=&amp;quot;@string/app_name&amp;quot;
            android:theme=&amp;quot;@style/AppTheme.NoActionBar&amp;quot;&amp;gt;
            &amp;lt;intent-filter&amp;gt;
                &amp;lt;action android:name=&amp;quot;android.intent.action.MAIN&amp;quot; /&amp;gt;
                &amp;lt;action android:name=&amp;quot;android.intent.action.VIEW&amp;quot; /&amp;gt;
                &amp;lt;category android:name=&amp;quot;android.intent.category.LAUNCHER&amp;quot; /&amp;gt;
            &amp;lt;/intent-filter&amp;gt;
        &amp;lt;/activity&amp;gt;
    &amp;lt;/application&amp;gt;

&amp;lt;/manifest&amp;gt;


public class BluetoothManageService extends Service implements BleManagerCallbacks{

    @Override
    public void onCreate() {
        super.onCreate();

        IntentFilter intentFilter = new IntentFilter();
		intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        registerReceiver(notificationReceive, intentFilter);
    }

    public final BroadcastReceiver NotificationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(final Context context, final Intent intent) {
            String action = intent.getAction();

            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
                final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF);
                final int previousState = intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_STATE, BluetoothAdapter.STATE_OFF);

                switch (state) {
                    case BluetoothAdapter.STATE_ON:
                        // On older phones (tested on Nexus 4 with Android 5.0.1) the Bluetooth requires some time
                        // after it has been enabled before some operations can start. Starting the GATT server here
                        // without a delay is very likely to cause a DeadObjectException from BluetoothManager#openGattServer(...).
                        break;

                    case BluetoothAdapter.STATE_TURNING_OFF:
                    case BluetoothAdapter.STATE_OFF:

                        break;
                }
            }
        }
    };
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/214143?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2019 11:40:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc5563f6-f0f0-4995-98ae-a60dec21e22b</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;If it doesn&amp;#39;t work automatically, there is no API you could use to enable it. Are you calling `createBond()`method, or trying to read a protected characteristic? None of this methods is working?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/213770?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 02:16:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8044676-db6c-479f-b846-3003db7d7a35</guid><dc:creator>sam</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;Aleksander:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; The first issue is solve &lt;span&gt;already.&lt;/span&gt;&lt;/p&gt;
&lt;div class="content full threaded-reply-content user-defined-markup"&gt;
&lt;div class="content"&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span&gt;Regarding the second issue,&amp;nbsp;just as you said HID device is enabled automatically if initiate bonding from android Setting by manual.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;But, if we use the Android-Scanner-Compat-Library and Android-BLE-Library to initial bonding, the HID device is not enabled automatically.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; Can we&amp;nbsp;do it by software, just like iPhone enabled it automatically after nRF52832 is bonded with android phone? And how to do?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thanks!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Sam&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="edit-form"&gt;&lt;/div&gt;
&lt;div class="actions meta default"&gt;
&lt;div class="navigation-list"&gt;
&lt;div class="container"&gt;
&lt;ul&gt;
&lt;li class="navigation-list-item vote"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android-BLE-Library development</title><link>https://devzone.nordicsemi.com/thread/211784?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 11:33:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62d1da81-73c5-4dfc-b0ce-bb8f4246bcbc</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Indeed, iOS reads the Device Name characteristic on it&amp;#39;s own after connection. Android, I think, does not. Instead, it exposes Generic Access service to the user (iOS does not), so you may read this characteristic after connection on your own, or often also write a value to change the name. We don&amp;#39;t recommend using BluetoothDevice.getName() as it&amp;#39;s using a cached name. For advertising packets is always better to use a name from the advertising data: &lt;a href="https://developer.android.com/reference/android/bluetooth/le/ScanRecord.html"&gt;https://developer.android.com/reference/android/bluetooth/le/ScanRecord.html&lt;/a&gt; -&amp;gt; getName().&lt;/p&gt;
&lt;p&gt;Regarding the second issue, when a HID device is bonded it should be enabled automatically. HID service is available form Android 4.4 onward. Perhaps you may have to initiate bonding from Android Settings -&amp;gt; [Connected Devices -&amp;gt;] Bluetooth.&lt;/p&gt;
&lt;p&gt;Hope that helped,&lt;/p&gt;
&lt;p&gt;Aleksander&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>