I have CAN library to read OBD PID values in Linux.
I created JNI layer and call the JNI API in my android application with simple activity and list view. I am able to read the CAN values properly in a loop.
But I have two issues:
1) I am using fragments in my android application. If I am using JNI library loading in fragments each time if I switch to other activity and come back to fragment library may be loading once again.
So what is the best way to use in fragments ?
2) Even If I am in any pages in android app, the CAN reading should happen in background and when the warning level exceeds notification should come (if not in the fragment where my gauges implemented) or if in fragment page then color indication should come in gauges which I implemented.
For this I need to create service ?
Please can any one suggest me how I can achivew second requiement ? Is Service implementation required ?
I am using Android Pie. How I can create CAN system service ?
If anyone worked on android CAN application please can you share the source code so that it will be helpful for me.