gpt4 book ai didi

android - 什么是 ZygoteInit 调用?

转载 作者:IT王子 更新时间:2023-10-28 23:29:44 25 4
gpt4 key购买 nike

我会定期在 Android Market 上收到无法重现的异常报告。堆栈跟踪总是这样开始:

at ...
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4306)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

ZygoteInit$MethodAndArgsCaller 似乎是直接调用应用程序方法,而不是通过代码。这是怎么回事?


最后重现了这些异常之一,如下:触摸应用图标,触摸文本字段以弹出对话框,按Home,杀死应用PID,触摸应用图标,然后按返回。在 onSaveInstanceState 和 onRestoreInstanceState 中添加了应用实例变量的保存和恢复以解决问题。

仍想在某处找到 ZygoteInit 调用的描述。

最佳答案

Lars Vogel 在 this article 中描述了 Zygote 进程在 Android 启动过程中的作用。 :

During startup of the Android system the Linux kernel first calls the process "init". init reads the files "/init.rc" and "init.device.rc". "init.device.rc" is device specific, on the virtual device this file is called "init.goldfish.rc".

init.rc starts the process "Zygote" via the program "/system/bin/app_process". Zygote loads the core Java classes and performs initial processing of them. These classes can be reused by Android application and therefore this step makes them faster to start. Once the initial work of Zygote is done, the process listens to a socket and waits for requests.

关于android - 什么是 ZygoteInit 调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6932630/

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