0

My application is processing data (which involves lot's of calculation, creation of arrays, clearing of those arrays) is it possible to resume from the place it left the calculation when the application resumes ?

While the calculation is going on I am showing a progress bar which cannot be cancelled using the back button, but in-case the user clicks the home button I do not want my calculation to be lost but instant stay exactly at the point till the application is run again and display the final results.

Thanks

====== Edit ======

I call ProcessingAsync().execute() in the onCreate method

The content of doInBackGround of my ProcesingAsync class is given below: (Using spinner and not horizontal progress bar to show the activity is going on)

@Override
        protected String doInBackground(String... aurl) {


                recordedDataFile = new  File(Environment.getExternalStorageDirectory().getPath(), "Machine_Health_Monitoring/Temporary_Files/Fault" + faultNumber + FORMAT_WAV);

                runThisCalculationMethod(2, recordedDataFile);  

                // showWaitingMessage becomes false after the runThisCalculationMethod() is completed           
                while(showWaitingMessage){
                    }

            return null;
        }
Sumit
  • 103
  • 1
  • 10

1 Answers1

0

You can create a marker (that shows in which part of the calculations you're at) and a partial-result and save it to a file. When you try resuming you'll first look in the file (if it exists) and continue from the last saved point. After you've finished all your calculations and displayed the results - make sure to delete the file.

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129