0

I need to create an object of the BLE class in the Activity, in onCreate, I tried to implement it with Parcel (passing the object via Intent), but I have an application crash from it.

As it turned out, the reason was that in the BLE class when I accept The content:

mDeviceListAdapter = getEnableIntent().getParcelableExtra("lVAdapter");
mDeviceListAdapter == null

Later I learned that the Intent serves to transfer data only in the onCreate from one Activity to another.

Please tell me how I can transfer objects of the created classes to other classes (not Activity). Thankful in advance.

Rajesh Pandya
  • 1,540
  • 4
  • 18
  • 31
Swype
  • 1
  • 4
  • Depends what's that second class of yours. If is a `fragment` that gets attached to your `activity` then you could make a public method inside activity and call it in fragment either by passing activity instance to fragment or just call `getActivity().yourPublicMethod();` . Make sure to check `getActivity()` before – Ionut J. Bejan Jul 06 '18 at 07:05
  • Is there any specific reason of not making class object Singleton or just static? – Salman Naseem Jul 06 '18 at 08:59
  • No, BLE is an ordinary class (not a fragment), in which is part of the logic of my application responsible for Bluetooth – Swype Jul 06 '18 at 09:05

0 Answers0