The loading bar is triggered for the microflow behind the button. If that microflow contains an action using the Java action you are referring to, that action is will run in a different thread, so it's not possible for the loader to track that action. You could include the action behind the Java action in the main microflow, and select 'non blocking' and 'asynchronous' from the microflow properties on the button. The loader will then be shown and the client will keep checking if the action is finished before the loader will disappear.
Looking at the microflow, are you perhaps retrieving a lot of data and want to process this in the background but still shown the user somewhere in your app how far it is?
If so, it might be an idea to , for example, Count the number of items you have retrieved in total, store that. Then, when processing , update the number that is updated and calculate the percentage that was been processed.
Now, add a loading bar somewhere in your app , combined with a microflow timer. Configure that to check how far the import is.
Is this a lot of work for something that can be better solved by the ideas above? Yes, it is ;) But its still a way to make this work for your situation, should it really be required.
Why wont to show a loading bar for microflows running in the background?
Think the concept of running it in the background is that the user can continue with whatever the user want to do, without being blocked by a running process. Thus if you want that the user waits before finishing, just execute the rest call etc directly in the called microflow.
We have a module that was built to display a progress bar for long running microflow that’s running in the background. We pass a Job object into the background microflow and update it periodically. We commit the job object in the background. A spinner is displayed to the user in a template grid [entity=Job, row=1, col=1, refresh=yes, sort=date created-desc]. Our use-case only had one user calling this microflow at a time, so if yours requires more, this might need to be adjusted (or might not work).