This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

customize the nrf toolbox app from github

I have customized the nrf toolbox app , facing the issues as below

1. I have created two pages , first page is used to scan and connect and second page is used to enter the data manually by user, respective data has to be sent to the device 

2. issue is , data which is entering manually is not receiving at the device side , and  more when i switch between the first page to second page , device is disconnecting. how to resolve this ? please guide me 

 first page 

second page 

Parents
  • Hello,

    First of all, a lot depends on your implementation. Remember that your Activity may be destroyed when switched to another one. Same with Fragment. You may either keep your connection in the service (you need to promote it to foreground service if you want to keep the connection also when the activity is not visible, otherwise Android 8+ may kill your service), or on ViewModel (see Architecture Components), but then you have to make sure the ViewModel is not dismissed as well. For example, you could hold your connection in a ViewModel bound to the Activity and use it in 2 fragments: one for scanning/connection, other for entering the data.

    There is number of possible solutions, each has pros and cons. I would recommend checking Android documentation regarding ViewModels, Services and our example in nRF Toolbox (RSC profile).

    Regards, Aleksander

Reply
  • Hello,

    First of all, a lot depends on your implementation. Remember that your Activity may be destroyed when switched to another one. Same with Fragment. You may either keep your connection in the service (you need to promote it to foreground service if you want to keep the connection also when the activity is not visible, otherwise Android 8+ may kill your service), or on ViewModel (see Architecture Components), but then you have to make sure the ViewModel is not dismissed as well. For example, you could hold your connection in a ViewModel bound to the Activity and use it in 2 fragments: one for scanning/connection, other for entering the data.

    There is number of possible solutions, each has pros and cons. I would recommend checking Android documentation regarding ViewModels, Services and our example in nRF Toolbox (RSC profile).

    Regards, Aleksander

Children
No Data
Related