我正在缩小范围并解释为尽可能简单, 主要活动启动异步任务。Android NullPointerException在屏幕方向更改
当方向改变onCreate()
被召回所以Async
创建一次获得。所以在onPreExecute()
我锁定我的方向,并在onPostExecute()
我释放锁定方向。通过这种方式,如果Async
任务已经开始,另一个任务实例将永远不会被创建。
另一个问题已经开始,主要活动本身findViewById()
返回null,当我随机保持改变屏幕方向。在5-6次尝试中重新产生一次。
该怎么办?任何帮助
请问方法或主线程完成后onCreate()
得到重新叫......或者是瞬时的,因为一旦方向得到改变
谢谢
-------- -------更新
<application
android:allowBackup="true"
android:icon="@drawable/ap_logo"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="agilepoint.android.mobilebpm.main.LoginActivity"
android:configChanges="orientation"
android:label="@string/app_name"
android:logo="@drawable/menu_button"
android:windowSoftInputMode="adjustPan|stateHidden"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent-filter>
</activity>
</application>
任何代码将有助于诊断问题 –
发布您的清单文件和错误跟踪。 –
您也可以在清单中禁用应用程序重新启动。此外,长时间运行的任务可以通过服务来处理。 – atok