gpt4 book ai didi

Android - 罕见的运行时异常,不指向它开始的任何类

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:37:13 26 4
gpt4 key购买 nike

我在应用程序上每 1000 多个 session 就会遇到一次此运行时异常,因此这种情况很少见,而且我无法重现它。

java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:381)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:226)
at android.view.Window$LocalWindowManager.removeView(Window.java:432)
at android.app.Dialog.dismissDialog(Dialog.java:278)
at android.app.Dialog.access$000(Dialog.java:71)
at android.app.Dialog$1.run(Dialog.java:111)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
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:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)

有谁知道如何重现它,或者它为什么会发生?或者更好的是,如何解决它? :)

谢谢!

编辑:

我添加了 Raghav 提出的建议:

<activity android:label="@string/app_name" 
android:configChanges="orientation|keyboardHidden"
android:name="ActivityName">

但这并没有解决崩溃问题,而且崩溃仍在发生。

编辑:

这是我使用的一些典型代码:

public class ProblemActivity extends BaseListActivity
{
Dialog dialog;

....


@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

...

// After some action
dialog.show();
}

public class GetSolutionTopicsTask extends AsyncTask<String, Void, String>
{
@Override
protected String doInBackground(String... theParams)
{
String myUrl = theParams[0];
String problem_id = theParams[1];

String charset = "UTF-8";
String response = null;

try
{
String query = String.format("problem_id=%s",
URLEncoder.encode(problem_id, charset));

final URL url = new URL( myUrl + "?" + query );

final HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setDoOutput(true);
conn.setRequestMethod("POST");

conn.setDoOutput(true);
conn.setUseCaches(false);

conn.connect();

final InputStream is = conn.getInputStream();
final byte[] buffer = new byte[8196];
int readCount;
final StringBuilder builder = new StringBuilder();
while ((readCount = is.read(buffer)) > -1)
{
builder.append(new String(buffer, 0, readCount));
}

response = builder.toString();
}
catch (Exception e)
{

}

return response;
}

@Override
protected void onPostExecute(String result)
{
if ( result == null )
{
try
{
dialog.dismiss();
} catch (Exception e) {
// nothing
}

}
else
{
try
{
dialog.dismiss();
}
catch (Exception e)
{
// nothing
}
} // End of else

}
}

最佳答案

ConfigChanges 不会导致此问题。

从上面的日志看来, Activity 中显示的对话框在 Activity 不再可见后被关闭。

如果您分享了代码或至少给出了导致崩溃所执行的步骤,我可以提出修复建议。

关于Android - 罕见的运行时异常,不指向它开始的任何类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13103237/

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