首页 > 解决方案 > Android中的android.os.TransactionTooLargeException错误

问题描述

我的 Android 应用程序返回android.os.TransactionTooLargeException时遇到问题,即使我清除了 Fragment 中的所有数据。

从我实现的片段 - 请参阅下面的代码,我开始一个新活动,该活动开始但一秒钟后android.os.TransactionTooLargeException被抛出。我试图清理所有捆绑包等,因此片段尽可能简单,但它会抛出:

java.lang.RuntimeException: android.os.TransactionTooLargeException: 数据包大小 608932 字节。

请问您知道问题出在哪里吗?

public class ShowDetailFragment extends Fragment {

  public static boolean was207Called = false;

  public interface ExpandViewListener {
    void onExpandClicked();
  }

  public void setFullScreenListener(ExpandViewListener listener) {
  }

  public ShowDetailFragment() {
  }

  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_show_detail, null, true);
    return v;
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
  }

  @Override
  public void onResume() {
    super.onResume();
  }

  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, null);
    Intent i = new Intent(getActivity().getApplicationContext(), ForgottenPasswordActivity.class);
    startActivity(i);
    return;
  }

  @Override
  public void onPause() {
    super.onPause();
  }

  @Override
  public void onSaveInstanceState(Bundle outState) {
  }

  public void onFragmentRemoved() {
    Log.d("XXXXX", "Frag removed");
  }

  @Override
  public void onStop() {
    super.onStop();
    Log.d("XXXX", "Stopping");
  }
}

标签: androidkotlinruntimeexception

解决方案


请试试 :-

public class ShowDetailFragment extends Fragment {

  public static boolean was207Called = false;

  public interface ExpandViewListener {
    void onExpandClicked();
  }

  public void setFullScreenListener(ExpandViewListener listener) {
  }

  public ShowDetailFragment() {
  }

  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_show_detail, container, false);
    return v;
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
  }

  @Override
  public void onResume() {
    super.onResume();

    Intent i = new Intent(getActivity(), 
    ForgottenPasswordActivity.class);
    startActivity(i);
  }

  public void onFragmentRemoved() {
    Log.d("XXXXX", "Frag removed");
  }

  @Override
  public void onStop() {
    super.onStop();
    Log.d("XXXX", "Stopping");
  }
}

推荐阅读