通过意图传递 BarEntry

Pass BarEntry through intent

我正在使用MPAndroidChart

我在服务中使用 BarEntry,我需要通过意图将 y 值推送到片段。由于 BarEntry 没有实现 Parcelable,我不知道该如何处理。

非常感谢!

您可以使用 extras 来发送必要的信息...如果您需要多个 BarEntry,这会很麻烦。

这是发件人:

Intent inten = new Intent(context, Main.class);
intent.putExtra("value", 23);
intent.putExtra("index", 1);

接收方:

Bundle bundle = intent.getExtras();
Float value = bundle.getFloat("value");
int index = bundle.getInt("index");
BarEntry barEntry = new BarEntry(value, index);