I have foreground service and need to do work on it. I get data from multiple sensors and I am currently sending them by constructor:
new MainMeranie(latitude, longitude, altitude, pressureAccuracy, GPSaltitude).start(); //first class needs to send data approximately every second
I know that its wrong because then previous variable data in the second class gets deleted (nulled)
public class MainMeranie extends Thread { //this is second class
static Double[] latitude = new Double[MAX_VALUE];
static Double[] longitude = new Double[MAX_VALUE];
static Doubl...//because it is executed by constructor all of variables needs to be static and I think this is not efficient way to do this.. or?
public MainMeranie(Double latitude, Double longitude, Double altitude, int pressureAccuracy, Double GPSaltitude) {
MainMeranie.latitude[i] = latitude*111139;
MainMeranie.longitude[i] = longitude*111139;
MainMe....
}
public void run() {...} //all work done here after constructor sets data
This needs to run on the foreground (it already is). I need second class to remember that data so it cant be activity or?? activity gets deleted when i kill app. I am starting a new thread every time because there is a lot of conditions and cycles..
What is the best, efficient way to do this?