EDIT 1:
This is the code that I have right now, trying to offload the heavy work on a separate thread.
protected override void OnCreate(Android.OS.Bundle bundle)
{
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
}
protected override void OnResume()
{
base.OnResume();
ThreadPool.QueueUserWorkItem(_ => BuildInterfaceForConnectedUser());
}
private void BuildInterfaceForConnectedUser()
{
RunOnUiThread(() => { UpdateInterface();});
}
The ability to display a progress bar while background work is in progress has been asked many times, like here or here.
My problem is that I'm building my main activity content dynamically based on incoming data. I'm downloading data during a splash activity so this is easy to run it as a background task (because no UI access in involved). On the other end, building the content could take several seconds and I'd like to inform the user of the progress.
Basically, there is a lot of work in OnResume(). Pseudo code:
protected override void OnResume()
{
base.OnResume();
UpdateInterface(); // Build the content dynamically
}
During all this time the main activity is not showing.
How can I make the main activity to be displayed blurred in the background with a progress bar while the final content is built ?
It is started like the following from a "Login" Activity:
Intent intent = new Intent(this, typeof(MainActivity));
if(Intent.Extras != null) intent.PutExtras(Intent.Extras);
StartActivity(intent);
All the samples I've seen so far are not working because they rely on a button click where the activity is already built.