Skip to content

Maintaining Connection Between Activities #21

@chirag-s

Description

@chirag-s

Hi could you suggest the ideal way to maintain connection between activities.

I am defining the BluetoothController as static in main activity and defining a local as follows
public BluetoothController mBluetoothController = MainActivity.mBluetoothController;

and then using that object i read the incoming data

mBluetoothController.setBluetoothListener(new BluetoothListener() { ... }

This works 90% of the time but i get this error at times
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x/com.x.yActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void co.lujun.lmbluetoothsdk.BluetoothController.setBluetoothListener(co.lujun.lmbluetoothsdk.base.BluetoothListener)' on a null object reference

Do let me know how i can resolve this issue !!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions