java - 将一个数组值从服务传递到活动
问题描述
我正在尝试通过传递一个从服务到活动不断变化的浮点数组值来制作实时折线图。
服务
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);
}
}
活动
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());
}
}
但在图表中,我只得到默认的 getFloatExtra() 值,这里是 30。您知道问题出在哪里,我该如何解决?提前致谢。
解决方案
推荐阅读
- sql - 嵌套的 select 语句与 from 和 where 都是唯一的?
- html - Bootstrap 关于覆盖样式的问题入门
- python - 使用列表推导删除与模式匹配的字典列表中的字典
- powershell - 在 Get-Aduser - directreports 中搜索特定条目
- pandas - 如何将多组数据放在一个条形图中?
- r - 问题从 tar 球构建 R 包
- google-apps-script - 使用 clasp 运行 Google Apps 脚本的默认项目
- entity-framework-core - 在引用列“Y”是标识列的情况下,无法创建级联外键“X”
- javascript - 如何在没有另一个数组javascript的情况下过滤数组
- database - 在 Flutter 中从 db 填充 GridView