我有一个应用程序,我正在尝试将 Xamarin UI 测试放在上面。我需要对应用程序进行后门以绕过我的登录过程。我的后门方法触发得很好。
[Activity(Label = "AppName", Icon = "@drawable/icon", Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
StartActivity(typeof(MainActivity));
}
[Java.Interop.Export("BackDoor")]
public void BackDoor()
{
var myActivity = {Magic code to get reference to the the instance of MainActivity goes here}
}
}
但是它在我的启动画面中触发,我需要它获得对我实际 MainActivity 的引用,而不是我的 SplashActivity。如何在 BackDoor 方法中获取对 MainActivity 的引用?
Xamarin 后门文档: https ://developer.xamarin.com/recipes/testcloud/start-activity-with-backdoor/ https://developer.xamarin.com/guides/testcloud/uitest/working-with/backdoors/