How to initiate background process(configuration) and show progress indicator until it finishes?
Yes, it could be achieved, You can set the visibility of progressbar to visible, and visibility of other controls is invisible in this Activity, If you have finish connect several devices using API calls, you can set the visibility of progressbar to invisible , other controls visibility to visible like this GIF.
I add a Task delay in this demo. you can replace your code about the connectseveral devices using API calls, but these code should be run in a thread, if progress of connection is done, you can set other controls visibility to visible, set the visibility of progressbar to invisible.
protected async override void OnCreate(Bundle savedInstanceState)
// Set our view from the "main" layout resource
ProgressBar progress_bar = FindViewById<ProgressBar>(Resource.Id.progress_bar);
Button button1 = FindViewById<Button>(Resource.Id.button1);
TextView textView1 = FindViewById<TextView>(Resource.Id.textView1);
progress_bar.Visibility = Android.Views.ViewStates.Invisible;
button1.Visibility = Android.Views.ViewStates.Visible;
textView1.Visibility = Android.Views.ViewStates.Visible;
Based on your description, I think that achieve a forground service is a good choice, then push a notification, show the progress in the notification.https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/services/foreground-services
Due to you initiate background process, this process is a time-consuming operation, It will make ANR easily(if not run it in service), and foreground service will make sure this initate process could be operated successfully, normally it will be killed by GCM.
Thanks LeonLu...While this seems to be appropriate for my question, I had another query. When the app starts for the first time and I want to connect several devices using API calls; so in order to achieve this I was thinking to show the round progress bar so that the user does not interact with the UI controls. However if the time is unkown, I don't want to hard code the timer...In that instance what would be the appropriate solution?
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies