I'm trying to make real-time line chart by passing one float array value, which is constanly changing, from service to activity.
Service
public Intent intentfusedOrientation;
public final void onCreate() {
//...
intentfusedOrientation = new Intent(this, Activity.class);
}
class calculateFusedOrientationTask extends TimerTask {
public void run() {
//...
intentfusedOrientation.putExtra("fusedOrientation", fusedOrientation[0]);
startService(intentfusedOrientation);
}
}
Activity
public void addEntry() {
LineData data = mChart.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
if (set == null) {
set = createSet();
data.addDataSet(set);
}
float fusedOrientation = getIntent().getFloatExtra("fusedOrientation",30);
data.addEntry(new Entry(set.getEntryCount(), fusedOrientation), 0);
data.notifyDataChanged();
mChart.notifyDataSetChanged();
mChart.setVisibleXRangeMaximum(150);
mChart.moveViewToX(data.getEntryCount());
}
}
But in a chart I'm only getting default getFloatExtra() value which is 30 here. Do you see what's the problem and how do I fix it? Thanks in advance.