I’m saving a fairly large bitmap in a background thread. It takes about a second. The main thread will try to load the same file into a canvas. How can I tell the main thread to wait until it has finished saving?
Edit:
I wanted to know how to check on the file, not how to wait; sorry for the misunderstanding.
The bitmap object was removed from the main thread’s memory for various reasons.
Is there a standard way to do check if the file is being used, or should I just use a workaround?
The
FileObserverclass suits your needs perfectly. Here is the documentation. It’s easy to use. When a observed file is closed after writing, theonEventcallback is called withCLOSE_WRITEas the parameter.