Okay, I finally found something I could use. It looks like the missing ProcessLifecycleOwner property I needed was hidden away within the Xamarin.AndroidX.Lifecycle.Extensions NuGet package. Why it is there is anyone's guess but after adding a reference to that, I was able to successfully subscribe my custom Application class to app-level lifecycle events.
I also needed to add the necessary attributes to my callback methods, including the [Export] attribute for some reason. This was documented in a StackOverflow answer and nowhere else.
Finally, before the project would compile with these changes, I needed to add a .dll reference (using the references modal, not NuGet, don't get tricked) to Mono.Droid.Export.dll, which was found under the Assemblies tree. To be fair, the Error output window told me what to do here so this one should be an easy fix if you forget to do it.
After making those changes, I was able to successfully compile the app, and get appropriate callbacks for when the app was backgrounded and foregrounded, which was exactly what I needed. See the below code for an example of what the custom Application class should look like to accomplish this.
using System;
using Android.App;
using Android.Runtime;
using AndroidX.Lifecycle;
using Java.Interop;
namespace MyAndroidApp
{
[Application]
public class MyApp : Application, ILifecycleObserver
{
public MyApp() { }
public MyApp(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer) { }
public override void OnCreate()
{
base.OnCreate();
ProcessLifecycleOwner.Get().Lifecycle.AddObserver(this);
}
[Export, Lifecycle.Event.OnStop]
public void OnAppBackgrounded()
{
// Handle background logic
}
[Export, Lifecycle.Event.OnStart]
public void OnAppForegrounded()
{
// Handle foreground logic
}
}
}