{"id":1119,"date":"2015-01-21T02:44:00","date_gmt":"2015-01-21T02:44:00","guid":{"rendered":"http:\/\/blog.zhukunqian.com\/?p=1119"},"modified":"2015-02-13T13:17:49","modified_gmt":"2015-02-13T13:17:49","slug":"unity-%e5%9c%a8%e6%b8%b8%e6%88%8f%e5%90%af%e5%8a%a8%e6%97%b6%e6%8c%89home%e9%94%ae%ef%bc%8c%e5%86%8d%e5%88%87%e5%9b%9e%e6%b8%b8%e6%88%8f%e9%bb%91%e5%b1%8f","status":"publish","type":"post","link":"https:\/\/blog.zhukunqian.com\/?p=1119","title":{"rendered":"unity \u5728\u6e38\u620f\u542f\u52a8\u65f6\u6309home\u952e\uff0c\u518d\u5207\u56de\u6e38\u620f\u9ed1\u5c4f"},"content":{"rendered":"<p>\u6211\u4eec\u7684\u6e38\u620f\u5728\u542f\u52a8\u65f6\uff0c\u5982\u679c\u5207\u56de\u540e\u53f0\uff0c\u4f1a\u51e0\u7387\u6027\u51fa\u73b0\u9ed1\u5c4f\u53ca\u8d44\u6e90\u52a0\u8f7d\u9519\u8bef\u3002<\/p>\n<p>\u6211\u6293\u4e86\u4e00\u4e0bandroid\u5c42\u7684\u5f02\u5e38\uff1a<\/p>\n<pre class=\"brush: bash; gutter: true\">01-20 22:21:48.362: W\/IInputConnectionWrapper(6525): showStatusIcon on inactive InputConnection\r\n01-20 22:21:48.440: E\/BufferQueue(190): [SurfaceView] connect: BufferQueue has been abandoned!\r\n01-20 22:21:48.440: E\/libEGL(6525): EGLNativeWindowType 0x76b53920 already connected to another API\r\n01-20 22:21:48.440: E\/libEGL(6525): eglCreateWindowSurface:525 error 3003 (EGL_BAD_ALLOC)\r\n01-20 22:21:48.440: E\/Unity(6525): [EGL] Failed to create surface\r\n01-20 22:21:48.440: E\/Unity(6525):  \r\n01-20 22:21:48.440: E\/Unity(6525): (Filename:  Line: 132)\r\n01-20 22:21:48.440: E\/Unity(6525): [EGL] Error:: EGL_BAD_ALLOC: EGL failed to allocate resources for the requested operation.\r\n01-20 22:21:48.440: E\/Unity(6525):  \r\n01-20 22:21:48.440: E\/Unity(6525): (Filename: .\/PlatformDependent\/AndroidPlayer\/ContextGLES.cpp Line: 132)\r\n01-20 22:21:48.441: E\/libEGL(6525): call to OpenGL ES API with no current context (logged once per thread)<\/pre>\n<p>\u5728\u7f51\u4e0a\u641c\u7d22\u4e86\u5f88\u591a\u6587\u7ae0\uff0c\u6ca1\u6709\u5408\u9002\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p>\u5728\u6d4b\u8bd5\u6211\u4eec\u516c\u53f8\u53e6\u4e00\u4e2a\u9879\u76ee\u7684\u6e38\u620f\u65f6\uff0c\u53d1\u73b0\u4ed6\u4eec\u6ca1\u6709\u8fd9\u4e2a\u95ee\u9898\uff0c\u6bd4\u8f83\u6211\u4eec\u4e24\u4e2a\u6e38\u620f\uff0c\u53d1\u73b0\u5728\u542f\u52a8\u901f\u5ea6\u4e0a\u5dee\u522b\u5f88\u5927\u3002<\/p>\n<p>\u611f\u89c9\u8fd9\u4e2a\u95ee\u9898\u7684\u51fa\u73b0\u548c\u542f\u52a8\u6162\u6709\u5173\u7cfb\u3002\u67e5\u770b\u542f\u52a8\u90e8\u5206\u4ee3\u7801\uff0c\u53d1\u73b0\u542f\u52a8\u7684\u7c7b\u7684field\u90fd\u662f\u76f4\u63a5\u5728\u7c7b\u52a0\u8f7d\u65f6\u8fdb\u884c\u7684\u521d\u59cb\u5316\u3002<\/p>\n<p>\u611f\u89c9\u8fd9\u91cc\u4f1a\u963b\u585e\u7ebf\u7a0b\uff0c\u5bfc\u81f4\u7684unity\u521d\u59cb\u65f6\u95f4\u975e\u5e38\u957f\u3002<\/p>\n<p>\u5199\u4e86\u4e00\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff0c\u5206\u522b\u5728Awake(),Start()\u53ca\u7c7b\u521d\u59cb\u5316\u65f6\u6dfb\u52a0Thread.sleep(15000)\u7684\u5f3a\u5236\u5ef6\u8fdf\u3002<\/p>\n<p>\u53d1\u73b0Awake,Start\u4e0d\u4f1a\u963b\u585eunity\u7684\u52a0\u8f7d\uff0c\u4f1a\u7acb\u5373\u52a0\u8f7d\u51fasplash image\u3002\u5728\u7c7b\u521d\u59cb\u5316\u65f6\uff0c\u6d88\u8017\u5927\u91cf\u65f6\u95f4\uff0c\u6253\u51faapk\u5305\uff0c\u5728\u624b\u673a\u4e0a\u8fd0\u884c\uff0c\u4e5f\u6ca1\u6709\u963b\u585esplash image\u663e\u793a\u3002\u8fd9\u4e0b\u53ef\u771f\u662f\u5947\u602a\u4e86\u3002<\/p>\n<p>\u6211\u5148\u628a\u6211\u4eec\u6e38\u620f\u4e2d\u5728\u7c7b\u52a0\u8f7d\u65f6\u521d\u59cb\u5316\u7684\u5185\u5bb9\u5168\u8f6c\u79fb\u81f3Awake\u4e2d\uff0c\u518d\u6253\u4e2a\u5305\u6d4b\u8bd5\u4e0b\u3002<\/p>\n<p>\u7ecf\u8fc7\u6211\u4eec\u8fd9\u8fb9\u548c\u73e0\u6d77\u6d4b\u8bd5\u56e2\u961f\u6d4b\u8bd5\uff0c\u8fdb\u6e38\u620f\u65f6\u4e22\u8d34\u56fe\u7684\u95ee\u9898\u6ca1\u6709\u518d\u6b21\u590d\u73b0\u3002\u662f\u4e2a\u597d\u6d88\u606f\u3002<\/p>\n<p>\u53ea\u5269\u4e0b\u6700\u540e\u4e00\u4e2a\u9ed1\u5c4f\u7684\u95ee\u9898\uff0c\u8fd9\u4e2a\u9ed1\u5c4f\u5e76\u4e0d\u662fBUG\uff0c\u53ea\u662f\u5ba2\u6237\u7aef\u4ee3\u7801\u6d41\u7a0b\u6ca1\u6709\u5904\u7406\u597d\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>2015.01.22 \u66f4\u65b0\uff1a<\/p>\n<p>\u672c\u6765\u4ee5\u4e3a\u9ed1\u5c4f\u662f\u6e38\u620f\u4e2d\u6545\u610f\u8bbe\u7f6e\u7684\u9ed1\u5c4f\uff0c\u628a\u6e38\u620f\u4e2d\u7684\u9ed1\u5c4f\u6539\u4e3a\u7eff\u5c4f\uff0c\u7ed3\u679c\u53d1\u73b0\u9ed1\u5c4f\u95ee\u9898\u4f9d\u65e7\u3002<\/p>\n<p>\u8bd5\u7740\u6293\u4e86\u4e00\u4e0b\u5f02\u5e38\uff1a<\/p>\n<pre class=\"brush: bash; gutter: true\">01-22 13:36:59.538: E\/XSJData(5438): serverId is null\r\n01-22 13:36:59.675: E\/XSJData(5438): serverId is null\r\n01-22 13:38:07.740: E\/linker(9195): load_library(linker.cpp:760): library &quot;libmaliinstr.so&quot; not found\r\n01-22 13:38:07.744: E\/(9195): appName=com.xsj.moon, acAppName=com.android.cts.openglperf\r\n01-22 13:38:07.744: E\/(9195): 0\r\n01-22 13:38:07.744: E\/(9195): appName=com.xsj.moon, acAppName=com.android.browser\r\n01-22 13:38:07.744: E\/(9195): 0\r\n01-22 13:38:13.985: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/mscorlib.dll.so&quot; not found\r\n01-22 13:38:14.501: E\/(9195): appName=com.xsj.moon, acAppName=com.android.cts.openglperf\r\n01-22 13:38:14.501: E\/(9195): 0\r\n01-22 13:38:14.501: E\/(9195): appName=com.xsj.moon, acAppName=com.android.browser\r\n01-22 13:38:14.501: E\/(9195): 0\r\n01-22 13:38:14.714: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/UnityEngine.dll.so&quot; not found\r\n01-22 13:38:14.800: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/Assembly-CSharp-firstpass.dll.so&quot; not found\r\n01-22 13:38:14.902: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/Assembly-CSharp.dll.so&quot; not found\r\n01-22 13:38:14.906: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/Assembly-UnityScript.dll.so&quot; not found\r\n01-22 13:38:14.909: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/HOTween.dll.so&quot; not found\r\n01-22 13:38:14.913: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/JsonFx.Json.dll.so&quot; not found\r\n01-22 13:38:14.916: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/P31RestKit.dll.so&quot; not found\r\n01-22 13:38:14.918: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/Vectrosity.dll.so&quot; not found\r\n01-22 13:38:14.919: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/UMGameAnalyticsLibForAndroid.dll.so&quot; not found\r\n01-22 13:38:14.920: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/UMGameAnalyticsLibForiOS.dll.so&quot; not found\r\n01-22 13:38:17.802: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/System.Core.dll.so&quot; not found\r\n01-22 13:38:17.872: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/System.dll.so&quot; not found\r\n01-22 13:38:18.303: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/System.Xml.dll.so&quot; not found\r\n01-22 13:38:19.756: E\/lsy(9195): UnityAwake\r\n01-22 13:38:20.957: E\/linker(9195): load_library(linker.cpp:760): library &quot;\/data\/app\/com.xsj.moon-1.apk\/assets\/bin\/Data\/Managed\/System.dll.so&quot; not found\r\n01-22 13:38:24.040: E\/linker(9195): load_library(linker.cpp:760): library &quot;fmod&quot; not found\r\n01-22 13:38:24.048: E\/linker(9195): load_library(linker.cpp:760): library &quot;fmodstudio&quot; not found\r\n01-22 13:38:24.062: E\/linker(9195): load_library(linker.cpp:760): library &quot;fmodstudio&quot; not found\r\n01-22 13:38:26.182: E\/linker(9195): load_library(linker.cpp:760): library &quot;fmodstudio&quot; not found\r\n01-22 13:38:26.252: E\/linker(9195): load_library(linker.cpp:760): library &quot;fmodstudio&quot; not found\r\n01-22 13:38:26.255: E\/linker(9195): load_library(linker.cpp:760): library &quot;fmod&quot; not found\r\n01-22 13:38:26.738: E\/XSJData(9195): serverId is null\r\n01-22 13:38:26.868: E\/XSJData(9195): serverId is null\r\n01-22 13:38:28.460: E\/WhetstoneSDK-JNI(9195): on Load native Whetstone<\/pre>\n<p>\u770b\u8d77\u6765\u8fd8\u662f\u7a0b\u5e8f\u4e2d\u6709BUG\uff0c\u5e76\u4e0d\u662f\u7b80\u5355\u7684\u903b\u8f91\u5f02\u5e38\u3002<\/p>\n<p>unity\u4e2d\u5305\u4e2d\u53ea\u5b58\u5728\u5bf9\u5e94\u7684dll\u4e0d\u5b58\u5728\u5bf9\u5e94\u7684dll.so\uff0c\u8fd9\u91cc\u5e94\u8be5\u662funity\u5185\u90e8\u7684\u52a0\u8f7d\u673a\u5236\u88ab\u7834\u574f\u6389\u4e86\u3002<\/p>\n<p>\u5728goolge\u4e0a\u641c\u7d22\u4e0bunity\u52a0\u8f7ddll\u7684\u6d41\u7a0b\u3002<\/p>\n<p>\u6293\u4e86\u4e00\u4e0b\u6b63\u5e38\u6d41\u7a0b\u7684\u65e5\u5fd7\uff0c\u5728\u6b63\u5e38\u6d41\u7a0b\u4e2d\u4e5f\u6709\u4e0a\u9762\u7684\u8f93\u51fa\u3002\u770b\u8d77\u6765\u4e0d\u662f\u4e0a\u9762\u7684\u539f\u56e0\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>2015.01.29<\/p>\n<p>\u8fd9\u51e0\u5929\u4e3a\u4e86\u8fd9\u4e2a\u82b1\u5c4f\uff0c\u9ed1\u5c4f\u7684\u95ee\u9898\u505a\u4e86\u4e0d\u4e86\u8c03\u67e5\uff0c\u73b0\u5728\u57fa\u672c\u4e0a\u786e\u8ba4\u4e86\u70b9\u4fe1\u606f\uff1a<\/p>\n<p>\u91cd\u73b0\u6d41\u7a0b\uff1a<\/p>\n<p>1\u3001\u542f\u52a8\u6e38\u620f<\/p>\n<p>2\u3001\u5728splash image\u52a0\u8f7d\u5b8c\u6210\u524d\uff0c\u70b9home\u952e\u8fd4\u56de\u4e3b\u754c\u9762<\/p>\n<p>3\u3001\u70b9\u6e38\u620f\u56fe\u6807\u8fdb\u5165\u6e38\u620f\uff0c\u51fa\u73b0\u9ed1\u5c4f\u3002\u5982\u679c\u7ee7\u7eed\uff0c\u5219\u6709\u53ef\u80fd\u51fa\u73b0\u82b1\u5c4f\u3002<\/p>\n<p>\u5df2\u7ecf\u786e\u8ba4\u7684\u4fe1\u606f\uff1a<\/p>\n<p>1\u3001\u6211\u4eec\u7684\u6e38\u620f\u4e2d\u5f88\u591a\u8d44\u6e90\u90fd\u653e\u5728\u7684resources\u76ee\u5f55\u4e0b\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u6e38\u620f\u52a0\u8f7d\u5f88\u6bd4\u8f83\u6162\uff0c\u8fd9\u91cc\u53ef\u80fd\u4f1a\u51fa\u73b0egl\u521d\u59cb\u5316\u672a\u5b8c\u6210\u65f6\uff0c\u70b9home\u952e\u8fd4\u56de\u754c\u9762\uff0c\u7136\u540e\u518d\u70b9\u56de\u6765\u65f6\uff0c\u53c8\u521b\u5efa\u4e86\u4e00\u6b21egl windows\uff0c\u800candroid\u4e2d\u4e0d\u5141\u8bb8\u540c\u65f6\u5b58\u5728\u4e24\u4e2aegl windows\uff0c\u6240\u4ee5\u5c31\u4f1a\u51fa\u73b0\u9ed1\u5c4f\u3002<\/p>\n<p>\u4e00\u6761\u53ef\u80fd\u6709\u7528\u7684\u4fe1\u606f\uff1a<\/p>\n<p>01-29 15:23:12.572: W\/MALI(3730): __egl_mali_post_to_window_surface:936: __egl_mali_post_to_window_surface: posting to window surface failed; couldn&#8217;t acquire output buffer (surface=0x7cb3b008)<\/p>\n<p>\u8fd8\u6709\u53e6\u4e00\u6761\uff0c\u4ece\u8fd9\u91cc\u5f00\u59cb\u4e0d\u505c\u62a5\u9519\uff1a<\/p>\n<p>01-29 15:23:12.573: D\/Unity(3730): [EGL] SwapBuffer: EGL_BAD_ALLOC: EGL failed to allocate resources for the requested operation.<br \/>\n01-29 15:23:12.933: E\/Unity(3730): [EGL] Failed to create surface<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<p>http:\/\/stackoverflow.com\/questions\/15561780\/createwindowsurface-failed-egl-bad-match<\/p>\n<p>\u53d1\u73b0\u4e00\u4ef6\u5f88\u5947\u602a\u7684\u4e8b\uff0c\u5728\u5c0f\u7c73\u624b\u673a\u4e0a\uff0c\u5982\u679c\u5b89\u88c5\u5b8c\u540e\u76f4\u63a5\u542f\u52a8\u6e38\u620f\uff0c\u5219\u5728\u6e38\u620f\u4e2d\u6309home\u952e\u8fd4\u56de\uff0c\u518d\u70b9\u6e38\u620f\u56fe\u6807\u8fdb\u5165\u6e38\u620f\uff0c\u6bcf\u6b21\u90fd\u4f1a\u91cd\u65b0\u8c03\u7528onCreate\u3002<\/p>\n<p>\u5982\u679c\u4e00\u5f00\u59cb\u4f7f\u7528\u6e38\u620ficon\u8fdb\u5165\u6e38\u620f\uff0c\u5219\u4e0d\u4f1a\u6709\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>\u53ef\u80fd\u6709\u7528\u7684\u4e00\u6761log:<\/p>\n<p>01-29 23:01:38.793: W\/ManagedEGLContext(18120): doTerminate failed: EGL count is 2 but managed count is 1<\/p>\n<p>\u9ed1\u5c4f\u7684\u539f\u56e0\u627e\u5230\u4e86\uff0c\u662f\u56e0\u4e3a4.3.1f1\u4e2dunity\u6bcf\u6b21pause\u540e\uff0ceglcontext\u9700\u8981\u91cd\u5efa\uff0c\u4f46\u6211\u4eec\u6e38\u620f\u4e2d\u91cd\u5efa\u9700\u8981\u7684\u65f6\u95f4\u592a\u957f\uff0c\u800c\u4e14\u5728\u91cd\u5efa\u5b8c\u6210\u524d\u5c31\u662f\u9ed1\u5c4f\uff0c\u800c\u4e14\u8fd9\u91cc\u8fd8\u6709\u53e6\u4e00\u4e2a\u95ee\u9898\uff0c\u5982\u679c\u5728\u9ed1\u5c4f\u671f\u518d\u6309pause\u8fd4\u56de\uff0c\u5219\u4f1a\u5bfc\u81f4\u6e38\u620f\u4e2d\u4e00\u4e2a10\u79d2\u7684\u9ed1\u5c4f\u7b49\u5f85\uff0c\u5982\u679c\u4f60\u77ed\u65f6\u95f4\u5185\u4e0d\u505cpause\uff0c\u5219\u6bcf\u4e00\u6b21puase\u5bfc\u81f4\u768410\u79d2\u7b49\u5f85\u4f1a\u7d2f\u52a0\u8d77\u6765\u3002<\/p>\n<p>\u53e6\u53c2\u8003\uff1ahttp:\/\/stackoverflow.com\/questions\/2112768\/prevent-onpause-from-trashing-opengl-context<\/p>\n<p>http:\/\/pastebin.com\/U4x5JjAr<\/p>\n<p>http:\/\/gamedev.stackexchange.com\/questions\/12629\/workaround-to-losing-the-opengl-context-when-android-pauses<\/p>\n<p>http:\/\/www.anddev.org\/android-2d-3d-graphics-opengl-problems-f55\/minimizing-opengl-texture-reloads-on-pause-resume-t52932.html<\/p>\n<p>&nbsp;<\/p>\n<p>https:\/\/code.google.com\/p\/replicaisland\/source\/browse\/trunk\/src\/com\/replica\/replicaisland\/GLSurfaceView.java<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>2015.02.03 \u4e0d\u77e5\u9053\u65f6\u95f4\u8fc7\u53bb\u591a\u957f\u4e86\uff0c\u9ed1\u5c4f\u548c\u82b1\u5c4f\u95ee\u9898\u7ec8\u4e8e\u5b9a\u4f4d\u5230\u4e86\uff0c\u9879\u76ee\u4ee3\u7801\u4e2d\u771f\u662f\u5404\u79cd\u5929\u5751\u3002<\/p>\n<p>\u5148\u5217\u4e0b\u89e3\u51b3\u65b9\u6848\u5427\uff1a<\/p>\n<pre class=\"brush: xml; gutter: true\">&amp;lt;activity\r\n            android:name=&quot;com.haifi.abc.MainActivity&quot;\r\n            android:configChanges=&quot;locale|mcc|mnc|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale&quot;\r\n            android:label=&quot;@string\/app_name&quot;\r\n            android:windowSoftInputMode=&quot;stateHidden&quot;\r\n            android:screenOrientation=&quot;sensorLandscape&quot;\r\n            android:theme=&quot;@android:style\/Theme.Black.NoTitleBar.Fullscreen&quot;&amp;gt;\r\n            &amp;lt;intent-filter&amp;gt;\r\n                &amp;lt;action android:name=&quot;android.intent.action.MAIN&quot; \/&amp;gt;\r\n                &amp;lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; \/&amp;gt;\r\n            &amp;lt;\/intent-filter&amp;gt;\r\n        &amp;lt;\/activity&amp;gt;\r\n        &amp;lt;activity android:label=&quot;@string\/app_name&quot; android:name=&quot;UnityPlayerActivityEx&quot; android:screenOrientation=&quot;landscape&quot; android:configChanges=&quot;locale|mcc|mnc|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale&quot;&amp;gt;\r\n            &lt;strong&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;lt;meta-data android:name=&quot;unityplayer.ForwardNativeEventsToDalvik&quot; android:value=&quot;false&quot; \/&amp;gt;&lt;\/span&gt;&lt;\/strong&gt;\r\n        &amp;lt;\/activity&amp;gt;<\/pre>\n<p>1\u3001\u4f7f\u7528unity\u4e2d\u63d0\u4f9b\u7684\u9ed8\u8ba4UnityPlayerActivity\uff0c\u662f\u4eceUnityPlayerNativeActivity\u7ee7\u627f\u800c\u6765\uff0c<\/p>\n<p>http:\/\/docs.unity3d.com\/Manual\/PluginsForAndroid.html<\/p>\n<p>\u8fd9\u91cc\u6709\u4e00\u6bb5\u5bf9UnityPlayerNativeActivity\u7684\u63cf\u8ff0\uff0c\u8bf4\u660e\u4e86unityplayer.ForwardnativeEventsToDalvik\u7684\u4f5c\u7528,<\/p>\n<p>\u6211\u4eec\u9879\u76ee\u4e2d\u4e0d\u77e5\u9053\u662f\u8c01\u7adf\u7136\u5220\u9664\u4e86\u8fd9\u4e9b\u4ee3\u7801\uff0cunity\u9ed8\u8ba4\u751f\u6210\u7684android\u5de5\u7a0b\u4e2d\u5e26\u7740\u6b64\u4ee3\u7801\u7684\u3002<\/p>\n<p>2\u3001\u81ea\u5df1\u5199\u4e00\u4e2a\u7c7b\u7ee7\u627f\u81eaUnityPlayerActivity\uff0c\u7136\u540e\u8865\u5145\u4ee5\u4e0b\u4ee3\u7801:<\/p>\n<pre class=\"brush: java; gutter: true\">\tprotected void onCreate(Bundle paramBundle) {\r\n\t\tsuper.onCreate(paramBundle);\r\n\t\tif (Build.VERSION.SDK_INT &gt;= 19) {\r\n\t\t\tgetWindow().getDecorView().setOnSystemUiVisibilityChangeListener(\r\n\t\t\t\t\tnew View.OnSystemUiVisibilityChangeListener() {\r\n\t\t\t\t\t\tpublic void onSystemUiVisibilityChange(\r\n\t\t\t\t\t\t\t\tint paramAnonymousInt) {\r\n\t\t\t\t\t\t\tView localView = UnityPlayerActivityEx.this\r\n\t\t\t\t\t\t\t\t\t.getWindow().getDecorView();\r\n\t\t\t\t\t\t\tif ((paramAnonymousInt &amp; 0x4) == 0) {\r\n\t\t\t\t\t\t\t\tlocalView.setSystemUiVisibility(5894);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tpublic void onWindowFocusChanged(boolean paramBoolean) {\r\n\t\tsuper.onWindowFocusChanged(paramBoolean);\r\n\t\tif ((Build.VERSION.SDK_INT &gt;= 14) &amp;&amp; (paramBoolean)) {\r\n\t\t\tgetWindow().setFlags(1024, 1024);\r\n\t\t\tgetWindow().getDecorView().setSystemUiVisibility(6);\r\n\t\t}\r\n\t\tif ((Build.VERSION.SDK_INT &gt;= 19) &amp;&amp; (paramBoolean)) {\r\n\t\t\tgetWindow().getDecorView().setSystemUiVisibility(5894);\r\n\t\t}\r\n\t}<\/pre>\n<p>OK\uff0c\u4ec0\u4e48\u82b1\u5c4f\u548c\u9ed1\u5c4f\u5168\u90fd\u6d88\u5931\u4e0d\u89c1\u4e86\u3002\u771f\u662f\u5929\u5751\u3002<\/p>\n<p>\u53e6\u5916\u8fd9\u91cc\u8fd8\u6709\u8fdb\u4e00\u6b65\u4f18\u5316\u7684\u4f59\u5730\uff1a\u53ef\u4ee5\u8fdb\u4e00\u6b65\u963b\u6b62surfaceview\u7684\u521b\u5efa\uff0c\u8fd9\u6837\u6309home\u952e\u518d\u8fd4\u56de\uff0c\u4e0d\u4f1a\u91cd\u5efaegl context\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>2015.02.13\u8bb0\u3002\u8fd9\u5468\u53c8\u5728\u5904\u7406\u8fd9\u4e2a\u95ee\u9898\uff0c\u5728MainActivity\u4e2d\u6dfb\u52a0\u4ee3\u7801\u540e\u53d1\u73b0\u5728\u7b2c\u4e00\u6b21\u5b89\u88c5\u540e\u76f4\u63a5\u5728\u5b89\u88c5\u754c\u9762\u542f\u52a8\uff0c\u6309home\u952e\u8fd4\u56de\uff0c\u518d\u70b9\u6e38\u620f\u56fe\u6807\uff0c\u5c31\u4f1a\u76f4\u63a5\u9ed1\u5c4f\u3002<\/p>\n<p>\u8fd9\u5468\u6012\u4e86\uff0c\u628aunity\u6e90\u7801\u5404\u4e2a\u51fd\u6570\u90fd\u6dfb\u52a0\u65e5\u5fd7\uff0c\u5728android\u90a3\u4e00\u5c42\u628a\u6240\u6709\u53ef\u80fd\u8c03\u7528\u7684\u51fd\u6570\u90fd\u6dfb\u52a0\u65e5\u5fd7\uff0c\u610f\u5916\u53d1\u73b0MainActivity\u7684onCreate\u88ab\u8c03\u7528\u4e86\u4e24\u6b21\uff1f\uff1f\uff1f\uff0c\u4e0d\u53ef\u7406\u89e3\uff0c\u4ece\u7406\u8bba\u4e0a\u8bb2\uff0cMainActivity\u7684onCreate\u6c38\u8fdc\u53ea\u4f1a\u88ab\u8c03\u7528\u4e00\u6b21\u3002<\/p>\n<p>\u53c8\u6dfb\u52a0\u6d4b\u8bd5\u4ee3\u7801\uff0c\u5728MainActivity\u4e2d\u8bbe\u7f6e\u4e00\u4e2aprivate static int m=0;\u5728onCreate\u4e2d\u8bbe\u7f6em++\uff0c\u7136\u540e\u8f93\u51fam\u7684\u503c\uff0c\u53d1\u73b0\u679c\u7136\uff0c\u4ece\u542f\u52a8\u754c\u9762\u542f\u52a8\u6e38\u620f\u65f6\uff0c\u6bcf\u6b21\u4ecehome\u952e\u8fd4\u56de\u90fd\u4f1a\u8c03\u7528onCreate\uff0c\u800c\u4e14m\u7684\u503c\u4e00\u76f4\u5728\u589e\u52a0\uff0c\u8bf4\u660e\u8fd9\u4e2a\u8fdb\u7a0b\u5e76\u6ca1\u6709\u88ab\u7ed3\u675f\u3002\u53ea\u662fMainActivity\u88ab\u91cd\u590d\u7684\u521b\u5efa\u3002<\/p>\n<p>\u6211\u4e00\u5f00\u59cb\u60f3\u5230\u7684\u65b9\u6cd5\u662f\u65e2\u7136MainActivity\u4e2d\u591a\u6b21\u521b\u5efa\uff0c\u90a3\u6839\u636em\u7684\u503c\uff0c\u53ea\u5728\u7b2c\u4e00\u6b21\u521b\u5efa\u65f6\uff0c\u751f\u6210unityPlayer\uff0c\u5176\u5b83\u7684\u65f6\u95f4\u4e0d\u518d\u91cd\u65b0\u521b\u5efaunityPlayer\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514dunityPlayer\u88ab\u591a\u6b21\u521b\u5efa\uff0c\u5c31\u4e5f\u81ea\u7136\u907f\u514d\u7684\u9ed1\u5c4f\u7684\u95ee\u9898\u3002<\/p>\n<p>\u4f46\u662f\u8fd9\u4e2a\u65b9\u6cd5\u4e00\u5f00\u59cb\u5f88\u597d\uff0c\u4f46\u5728\u6d4b\u8bd5\u4e2d\u53d1\u73b0\u4e86\u95ee\u9898\uff0c\u6211\u4eec\u5f00\u59cb\u6e38\u620f\u65f6\uff0c\u4f1a\u64ad\u653e\u4e00\u4e2amp4\u89c6\u9891\uff0c\u5982\u679c\u8fd9\u65f6\u5019\u6309home\u8fd4\u56de\uff0c\u518d\u8fd4\u56de\u6e38\u620f\uff0c\u53c8\u662f\u9ed1\u5c4f\uff0c\u8be5\u6b7b\uff0c\u8fd9\u662f\u56e0\u4e3a\u6211\u4eec\u7684\u5f00\u53d1\u4eba\u5458\u628a\u64ad\u653e\u89c6\u9891\u653e\u5728\u4e86MainActivity\u4e2d\uff0c\u800c\u8fd4\u56de\u65f6\uff0c\u53c8\u56e0\u4e3aonCreate\u7684\u539f\u56e0\uff0c\u53c8\u4e22\u5931\u6389\u4e86\u64ad\u653e\u89c6\u9891\u7684view\u3002<\/p>\n<p>\u603b\u4e4b\uff0c\u8d70\u4e86NNNNNNN\u591a\u7684\u5f2f\u8def\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\u6211\u53c8\u91cd\u65b0\u5ba1\u89c6\u4e86\u81ea\u5df1\u7684\u89e3\u51b3\u65b9\u6cd5\u548c\u95ee\u9898\u6839\u6e90\uff0c\u8fd9\u91cc\u6839\u6e90\u5c31\u662f\u56e0\u4e3aonCreate\u88ab\u8c03\u7528\u4e86\u591a\u6b21\u5bfc\u81f4\u7684\uff0c\u5982\u679c\u80fd\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5176\u5b83\u6240\u6709\u95ee\u9898\u90fd\u662f\u81ea\u7136\u800c\u89e3\u3002<\/p>\n<p>\u5e78\u597d\u8001\u5916\u65e9\u5c31\u9047\u5230\u95ee\u9898\u4e86\uff0c\u53ea\u662f\u53ef\u60dc\u6211\u4e00\u5f00\u59cb\u6ca1\u6709\u8d70\u5230\u6b63\u786e\u7684\u65b9\u5411\uff0c\u5bfc\u81f4\u82b1\u8d39\u4e86\u592a\u591a\u7684\u65f6\u95f4\u3002<\/p>\n<p>\u597d\u5427\u4e0b\u9762\u662f\u4e00\u7cfb\u5217\u7684\u5947\u9047\uff1a<\/p>\n<p>1\u3001\u6211\u5728google\u641c\u7d22: &#8220;android acitivity recreate from home button&#8221;<\/p>\n<p>2\u3001\u5b83\u5efa\u8bae\u6211\u641c\u7d22\uff1a &#8220;android activity oncreate from home button&#8221;\uff0c\u597d\u5427\uff0c\u540c\u610f\u5b83\u3002<\/p>\n<p>3\u3001\u770b\u5230\u4e00\u4e2a\u641c\u7d22\u7ed3\u679c\uff1ahttp:\/\/stackoverflow.com\/questions\/16981793\/android-home-key-issue-at-first-time-calling-oncreate<\/p>\n<p>4\u3001\u679c\u7136\u662f\u6211\u9700\u8981\u7684\u95ee\u9898\uff0c\u91cc\u9762\u5efa\u8bae\u53bb\uff1a<a href=\"http:\/\/code.google.com\/p\/android\/issues\/detail?id=2373\" rel=\"nofollow\">http:\/\/code.google.com\/p\/android\/issues\/detail?id=2373<\/a><\/p>\n<p>5\u3001https:\/\/code.google.com\/p\/android\/issues\/detail?id=2373\u3000\u597d\u5427\uff0c\u679c\u7136\u662f\u5b9d\u5730\uff0c\u95ee\u9898\u6839\u6e90\u53ca\u89e3\u51b3\u65b9\u6848\uff08\u4e09\u79cd\uff09\u90fd\u5728\u91cc\u9762\u3002<\/p>\n<p>\u8fd9\u91cc\u6211\u91c7\u7528\u4e86\uff0c\u8fd9\u4e2a\u5927\u5e08\u7684\u89e3\u51b3\u65b9\u6848\u3002\uff08\u5f53\u7136\uff0c\u53e6\u5916\u7684\u89e3\u51b3\u65b9\u6848\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\uff09<\/p>\n<pre>&lt;a href=&quot;https:\/\/github.com\/cleverua\/android_startup_activity&quot; rel=&quot;nofollow&quot;&gt;https:\/\/github.com\/cleverua\/android_startup_activity&lt;\/a&gt;<\/pre>\n<p>\u603b\u7ed3\uff1a\u4e5f\u662f\u81ea\u5df1\u592a\u4e0d\u4e86\u89e3android\u5f00\u53d1\u4e86\uff0c\u4e0d\u7136\u8fd9\u4e2abug\u4e00\u770b\u5230\u5c31\u53ef\u4ee5\u89e3\u51b3\u6389\u4e86\u3002\u81ea\u5df1\u867d\u7136\u82b1\u8d39\u5f88\u591a\u7cbe\u529b\uff0c\u4f46\u4e2d\u95f4\u89e3\u51b3\u95ee\u9898\u7684\u5b66\u4e60\u4e5f\u8ba9\u81ea\u5df1\u589e\u957f\u4e86\u4e0d\u957f\u89c1\u8bc6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u7684\u6e38\u620f\u5728\u542f\u52a8\u65f6\uff0c\u5982\u679c\u5207\u56de\u540e\u53f0\uff0c\u4f1a\u51e0\u7387\u6027\u51fa\u73b0\u9ed1\u5c4f\u53ca\u8d44\u6e90\u52a0\u8f7d\u9519\u8bef\u3002 \u6211\u6293\u4e86\u4e00\u4e0ba &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/blog.zhukunqian.com\/?p=1119\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=\/wp\/v2\/posts\/1119"}],"collection":[{"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1119"}],"version-history":[{"count":13,"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=\/wp\/v2\/posts\/1119\/revisions"}],"predecessor-version":[{"id":1152,"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=\/wp\/v2\/posts\/1119\/revisions\/1152"}],"wp:attachment":[{"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhukunqian.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}