Activity pause timeout on ActivityRecord when running in release mode

Hi All

I need help on this error. I am getting data from my web api and loading on my tablayout with viewpager. When running the application in debug mode everything works fine but when i run the application release it crashes as shown below

Here is my code :smile:

TabLayout tabLayout;
    ViewPager viewpager;
    TextView conf_name;
    Android.Support.V4.App.Fragment[] fragments;
    ConferenceDayService conferenceDayService;
    Java.Lang.ICharSequence[] titles;
    async protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.ProgrammeActivity);
        RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;

        var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
        conf_name = FindViewById<TextView>(Resource.Id.conf_title);
        conf_name.Text = "Programme";
        SetSupportActionBar(toolbar);
        SupportActionBar.SetDisplayHomeAsUpEnabled(true);

        tabLayout = FindViewById<TabLayout>(Resource.Id.sliding_tabs);
        ProgressDialog progressdialog = new ProgressDialog(this);
        progressdialog.SetCancelable(false);
        progressdialog.Indeterminate = true;
        progressdialog.SetMessage("Loading...");
        progressdialog.SetProgressStyle(ProgressDialogStyle.Spinner);
        progressdialog.Show();
        await InitTabLayout();
        progressdialog.Hide();
        progressdialog.Dismiss();

    }
    private async Task LoadFragmentsData()
    {

        conferenceDayService = new ConferenceDayService();
        await Task.Run(() => conferenceDayService.GetAllConferenceDay(Constants.ProgrammesConferenceDays));
        var conferencedays = conferenceDayService.ConferenceDays.OrderBy(c => c.ConferenceDate).ToList();
        fragments = new Android.Support.V4.App.Fragment[conferencedays.Count];
        string[] tabtitles = new string[conferencedays.Count];
        for (int i = 0; i < conferencedays.Count; i++)
        {
            fragments[i] = new FirstDayFragment(conferencedays[i].programme.OrderBy(c=>c.StartTime).ToList(),
                                               conferencedays[i]);
            tabtitles[i] = $"{conferencedays[i].ConferenceDate.Date.Day.DisplayWithSuffix()} of " +
                $"{conferencedays[i].ConferenceDate.Date.ToString("MMMM")}";
        }
        titles = CharSequence.ArrayFromStringArray(tabtitles); 
    }
    private async Task InitTabLayout()
    {

        if (isOnline())
        {
            tabLayout.SetTabTextColors(Android.Graphics.Color.Aqua, Android.Graphics.Color.AntiqueWhite);
            await LoadFragmentsData();

            viewpager = FindViewById<ViewPager>(Resource.Id.tabviewpager);
            viewpager.Adapter = new TabFragmentsPageAdapter(this.SupportFragmentManager,
                fragments, titles);
            viewpager.Adapter.NotifyDataSetChanged();
            //viewpager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
            //viewpager.PageSelected += ViewPageSelected;
            tabLayout.SetupWithViewPager(viewpager);

            tabLayout.AddOnTabSelectedListener(this); 
        }
        else
        {
            new Android.Support.V7.App.AlertDialog.Builder(this)
                    .SetPositiveButton("Yes", (sender, args) =>
                    {
                        // User pressed yes
                    })
                    .SetNegativeButton("No", (sender, args) =>
                    {
                        Finish();
                    })
                    .SetMessage("No network connection. You won't be able to get data")
                    .SetTitle("Network Error")
                    .Show();
        }
        //ConferenceUtils.FillTextTabForAllScreens(ref tabLayout,this);

    }

Any help will be really appreciated as this error has kept stagnant for days. Please I am doing wrong here.

Sign In or Register to comment.