I need to move an object from an activity to a service. This is my attempt at the Activity side.
Waveform waveform = new Waveform();
Intent intent = new Intent(this, StimulationService.class);
Bundle bundle = new Bundle();
bundle.putParcelable("test", (Parcelable) waveform);
intent.putExtras(bundle);
startService(intent);
I have placed this code in the onStart() function in the service.
Bundle bundle = this.getIntent().getExtras();
if(bundle!=null)
mWaveform = bundle.getParcelable(waveform);
I’m getting errors for the function “getIntent” and “waveform” inside the getParcelable().
Any help or guidance is appreciated.
getIntentmethod. Instead the intent is passed in as an argument to theonStartmethod. So you should use that parameter instead.getParcelablemethod takes aString, which in the case of your test code, should be"test".