0

I have an overlay activity that starts before my app executes long running operations and closes it after ending that operation. The operation works fine, but the overlay activity doesn't show up.

btnVerify.Enabled = false;
Intent i = new Intent(this, typeof(Overlay));
i.AddFlags(ActivityFlags.NewTask);
StartActivity(i);

new System.Threading.Thread(new System.Threading.ThreadStart(() =>
{
    RunOnUiThread(delegate
    {
        {    
            object Token = RSMobile.Class.BLL.Member.MemberData.GetActivationKey(PhoneNumber);
            if (Token != null && !string.IsNullOrEmpty(Token.ToString()))
            {
                RSProperties.Token = Token.ToString();

                //ActivationKey sent to phonenumber,waiting for enter that
                Intent myIntent = new Intent();
                myIntent.PutExtra("PhoneNumber", PhoneNumber);
                myIntent.PutExtra("IdLanguage", spLanguage.SelectedItemPosition);
                myIntent.SetClass(this, typeof(CheckActivationKey));
                myIntent.AddFlags(ActivityFlags.NewTask);
                StartActivity(myIntent);
                //Finish();
            }
            else
            {
                myToast.MakeText(this, "خطا در احراز هویت", ToastLength.Long);
            }

            btnVerify.Enabled = true;
            Overlay.CurrentActivity.Finish();
        }
    });
})).Start();
Sven-Michael Stübe
  • 14,560
  • 4
  • 52
  • 103
Mohsen.Sharify
  • 259
  • 4
  • 11

1 Answers1

0

I would not recommend using an Activity for this if you are wanting to return to the previous screen when the long-running operation completes.

Can you just use an Android View of some kind instead, that covers the entire screen? A good option might be ProgressDialog or just a View using an indeterminate ProgressBar.

jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
  • thanks for your reply,i tested ProgressBar,i want to customize and full screened like iOS progress design with loading picture,can you explain how can i do it,or views if that is better? – Mohsen.Sharify Mar 14 '16 at 04:23
  • So you need to just make a custom `View` that looks like you want instead of a full `Activity`. This guy has a decent walkthrough: http://syedwasihaider.github.io/blog/2015/07/12/XamarinViews/ – jonathanpeppers Mar 14 '16 at 16:36