Xamarin.Mac:在沙箱中启动另一个带参数的应用程序

时间:2018-03-20 17:03:22

标签: xamarin xamarin.mac

我使用本教程在登录时为我的应用程序实现了启动: https://blog.timschroeder.net/2012/07/03/the-launch-at-login-sandbox-project/

基本上,您需要实施一个Helper应用程序,该应用程序将在登录时开始注册,Helper将启动您的应用程序。

问题是我想隐藏启动我的应用程序,为此我需要传递一个参数。不幸的是,我没有找到任何办法。

我找到了这些方法来启动App:

//Works to launch the app but no way to pass arg
var app = SBApplication.FromBundleIdentifier(PackageId);
app?.Activate();

//Same issue here
NSWorkspace.SharedWorkspace.OpenFile("/Applications/HelloWorld.app")

//If you run the code bellow outside of the sandbox it works fine.
//Inside of the sandbox it just launches the app but without args
var aTask = NSTask.LaunchFromPath("/usr/bin/open", 
                new string[] { "-a","HelloWorld.app", "--args", "--hidden" });
aTask.Launch();

0 个答案:

没有答案
相关问题