Search Unity

How to Manager Callbacks from Native Andrioid to Unity.

Discussion in 'Android' started by Ankit_JeGames, Sep 16, 2019.

  1. Ankit_JeGames

    Ankit_JeGames

    Joined:
    May 28, 2019
    Posts:
    11
    Hey Folks,

    I'm working on an app which communicate with a Bluetooth device. In this communication my app will send some commands and then Bluetooth device will respond with some data.

    I'm writing Android native plugin for this in Android communicating with Bluetooth device is very easy, but In order to receive message from Bluetooth device I need to implement an Interface in Android which handles all the callbacks in Native. The Interface needed to Implement is "Bluetooth.CommunicationCallback" and methods of it listed below
    Code (CSharp):
    1. public void onConnect(BluetoothDevice device)
    2. public void onDisconnect(BluetoothDevice device, String message)
    3. public void onMessage(String message)
    4. public void onError(String message)
    5. public void onConnectError(final BluetoothDevice device, String message)
    Now my question is that How can I trigger an event in unity when ever one of these methods get called.

    I've also tried this plugin as well but did not work for me.
    LInk https://assetstore.unity.com/packages/tools/input-management/nativebt-75782

    Any thing will help just point me in to right direction.


    Thank you.