gpt4 book ai didi

android - Xamarin - Mono 和 Android 通信

转载 作者:搜寻专家 更新时间:2023-11-01 07:47:56 24 4
gpt4 key购买 nike

我正在浏览 Xamarin 文档 https://developer.xamarin.com/guides/android/under_the_hood/architecture/它说

"Xamarin.Android applications run within the Mono execution environment. This execution environment runs side-by-side with the Android Runtime (ART) virtual machine. Both runtime environments run on top of the Linux kernel and expose various APIs to the user code that allows developers to access the underlying system"

据我了解,应用程序是单个进程 - 说有两个执行环境是什么意思?这两个环境是不是在同一个进程的不同线程中启动的?还是像 Android 运行时启动然后启动 Mono 运行时?

最佳答案

您只需进一步阅读 Application Startup . Runtime 在进程创建期间被加载:

Xamarin.Android hooks into this by adding a mono.MonoRuntimeProvider ContentProvider to AndroidManifest.xml during the build process. The mono.MonoRuntimeProvider.attachInfo() method is responsible for loading the Mono runtime into the process. Any attempts to use Mono prior to this point will fail. ( Note: This is why types which subclass Android.App.Application need to provide an (IntPtr, JniHandleOwnership) constructor, as the Application instance is created before Mono can be initialized.)

AndroidManifest.xml 中提到的部分如下所示:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foo.sample" android:installLocation="auto"
android:versionCode="1" android:versionName="1.0">
<application ...>

<provider android:name="mono.MonoRuntimeProvider"
android:exported="false" android:initOrder="2147483647"
android:authorities="foo.sample.mono.MonoRuntimeProvider.__mono_init__" />

</application>
</manifest>

关于android - Xamarin - Mono 和 Android 通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39945382/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com