试图显示对话框片段时,非法验证



我在Google-play游戏机上获得IllegalStateException,我无法复制,我不明白是什么问题。

这是Google-Play Console的日志

java.lang.RuntimeException: 
    at com.loopj.android.http.AsyncHttpResponseHandler.onUserException (AsyncHttpResponseHandler.java:304)
    at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage (AsyncHttpResponseHandler.java:395)
    at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage (AsyncHttpResponseHandler.java:510)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:148)
    at android.app.ActivityThread.main (ActivityThread.java:5441)
    at java.lang.reflect.Method.invoke (Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:738)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:628)
Caused by: java.lang.IllegalStateException: 
    at android.support.v4.app.FragmentManagerImpl.enqueueAction (FragmentManager.java:1515)
    at android.support.v4.app.BackStackRecord.commitInternal (BackStackRecord.java:638)
    at android.support.v4.app.BackStackRecord.commit (BackStackRecord.java:617)
    at android.support.v4.app.DialogFragment.show (DialogFragment.java:139)
    at com.example.eliran.forum.ForumFragment.regularTopic (ForumFragment.java:240)
    at com.example.eliran.forum.ForumFragment.enterTopic (ForumFragment.java:225)
    at com.example.eliran.forum.ForumFragment$13.onSuccess (ForumFragment.java:620)
    at com.loopj.android.http.TextHttpResponseHandler.onSuccess (TextHttpResponseHandler.java:118)
    at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage (AsyncHttpResponseHandler.java:351)

根据我附加的日志,流是这样的:

  1. 创建的片段和使用AsynchttpClient的功能。
  2. AsynchttpClient完成了成功结果,返回JSON对象。
  3. 与JSON的AsynchttpClclient成功呼叫。
  4. 对调节的肠道通话。
  5. 在此功能(调节)中发生。这是功能:

    public void regularTopic(ForumTopic forumTopic, int positionInArray) {
        FragmentManager fm = getChildFragmentManager();
        ForumTopicDialogFragment dialogFragment = new 
        ForumTopicDialogFragment();
        dialogFragment.setTargetFragment(this,100);
        Bundle bundle = new Bundle();
        bundle.putInt("posInArray", positionInArray);
        bundle.putSerializable("topic", forumTopic);
        dialogFragment.setArguments(bundle);
        dialogFragment.show(fm, ""); }
    

这是AsynchttpClient请求(OnSuccess应该从UITHREAD运行):

AsyncHttpClient client = new AsyncHttpClient();
String url = TheFinals.HOST + "/topics/" + id;
client.get(url, new TextHttpResponseHandler() {
    @Override
    public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
    }
    @Override
    public void onSuccess(int statusCode, Header[] headers, String responseString) {
        try {
            JSONArray topic = new JSONArray(responseString);
            if (topic.length() > 0) {
                JSONObject jsonObject = topic.getJSONObject(0);
                ForumTopic forumTopic = new ForumTopic(jsonObject.getInt("id"), jsonObject.getInt("userid"),
                        jsonObject.getString("content"), jsonObject.getString("title"), jsonObject.getString("firstname"),
                        jsonObject.getString("time"), jsonObject.getInt("icon"), jsonObject.getString("fbid")
                        , jsonObject.getInt("status"), jsonObject.getInt("anonymous"), jsonObject.getInt("catid"), jsonObject.getString("picture"));
                ForumFragment.this.enterTopic(forumTopic, -1);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
});

有人可以帮忙吗?首先,我需要在手机中复制此问题:

此问题与此错误有关。我通过覆盖对话框片段中的节目方法解决了它:

@Override
public void show(FragmentManager manager, String tag) {
    try {
        FragmentTransaction ft = manager.beginTransaction();
        ft.add(this, tag).addToBackStack(null);
        ft.commitAllowingStateLoss();
    } catch (IllegalStateException e) {
        Log.e("IllegalStateException", "Exception", e);
    }
}

尝试在500ms延迟后呼叫续集:

//declare this as global variable on your activity
final Handler handler = new Handler();

handler.postDelayed(new Runnable() {
  @Override
  public void run() {
    ForumFragment.this.enterTopic(forumTopic, -1);
  }
}, 500);

相关内容

  • 没有找到相关文章

最新更新