Skip to content Skip to sidebar Skip to footer

Android Nearby Not Working On Android Things

I have have the following code: OnFailureListener onFailureListener = new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.e(TAG, 'bum', e)

Solution 1:

Adding to Varun's answer, I'm going to guess that the default launcher is still running and hogging Connections. The IoT launcher will look something like this:

enter image description here

You can make your app the home app by adding an intent-filter to the manifest, like so (official documentation):

<applicationandroid:label="@string/app_name"><activityandroid:name=".HomeActivity"><!-- Launch activity as default from Android Studio --><intent-filter><actionandroid:name="android.intent.action.MAIN"/><categoryandroid:name="android.intent.category.LAUNCHER"/></intent-filter><!-- Launch activity automatically on boot, and re-launch if the app terminates. --><intent-filter><actionandroid:name="android.intent.action.MAIN"/><categoryandroid:name="android.intent.category.HOME"/><categoryandroid:name="android.intent.category.DEFAULT"/></intent-filter></activity>

Once you add the intent-filter to your manifest and install + run your app, you'll want to make sure the default launcher is no longer running. The easiest way to do this is to just reboot your Android Things device. Since your app is now the home app, it'll be the first app to launch after the reboot.

I'm not sure what Android Things version/system image you have, but you might also be able to do with one of the following adb commands:

adb shell am force-stop com.android.iotlauncher.ota

or maybe:

adb shell am force-stop com.android.iotlauncher

Solution 2:

The version of Play Services is fixed to each release on Android Things, not updated automatically through the Play Store (see Google Services for more details on how Play Service works on Android Things). Because of this, you need to select a client library version for Nearby that will work with the 12.5.20 Play Services APK.

You may have success with a later version as well, but 12.0.1 is a known tested version of the Nearby client with Android Things 1.0.x:

dependencies {
    ...
    implementation "com.google.android.gms:play-services-nearby:12.0.1"
}

Solution 3:

Error code 8050 is API_CONNECTION_FAILED_ALREADY_IN_USE -- you can read more about that here.

Essentially, Nearby Connections doesn't (yet) support multiple clients using it, so there's some other app already using it that needs to be killed -- it's likely to be the app that sets up your Android Things device.

Post a Comment for "Android Nearby Not Working On Android Things"