I have a modified version of the application for the bluetooth chat example. I installed a ScheduledExecutorService that sends a command via bluetooth at a predetermined speed using scheduleAtFixedRate .
I set PreferenceActivity so the user can change the period. But I'm not sure how to get current recurring tasks with an updated period. Do I need to somehow cancel and restart the ScheduledExecutorService ?
Here are the relevant parts of my code.
private ScheduledExecutorService scheduleTaskExecutor; public long ReadInterval = 1; ... @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); scheduleTaskExecutor = Executors.newScheduledThreadPool(5); ...
And I tried to update ReadInterval here. ReadInterval updated, but the recurring period of the command is not updated.
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (D) Log.d(TAG, "onActivityResult " + resultCode); switch (requestCode) { case REQUEST_CONNECT_DEVICE: ... case REQUEST_ENABLE_BT: ... case REQUEST_SETTINGS:
source share