Skip to content
Advertisement

Google Nearby Messages API: Attempting to perform a high-power operation from a non-Activity Context

Calling subscribe on the Google Nearby Messages API for Android results in the Exception:

JavaScript

My code:

JavaScript

Note: The promise Parameter is from React Native, I’m trying to create a wrapper for the API.

At the Log.d event inside my OnCompleteListener, it prints:

JavaScript

I do have the API Key and the required Permissions (BLUETOOTH, BLUETOOTH_ADMIN) in my AndroidManifest.xml.

On iOS the API calls work fine.

Advertisement

Answer

Solved it! The context

JavaScript

is not a valid Activity Context for the Nearby API! I had to use

JavaScript

which is a method from the base class ReactContextBaseJavaModule.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement