1

This error occurred when I opened an activity from a fragment. The new activity contain a viewPager and I think the error is caused by the new activity because when I block a section of code (viewPager.setAdapter(adapter)),the error disappears and I can see the new activity. So I think the intent is causing no problem.

Here is my fragment code

getActivity().startActivity(new  Intent(getActivity(),five_oder.class));

The new activity main code

    viewPager= (ViewPager) findViewById(R.id.oder_viewPafer);
     tb= (PagerTabStrip) findViewById(R.id.order_tab);
     TitleList = new ArrayList<String>();
     fragmentList = new ArrayList<Fragment>();
     TitleList.add("已完成订单");
     TitleList.add("未完成订单");
     fragmentList.add(new fragment_oder1());
     fragmentList.add(new fragment_oder2());
     MyFragmentAdapter adapter=new  MyFragmentAdapter(getSupportFragmentManager(),fragmentList,TitleList);
    viewPager.setAdapter(adapter);

Adapter code

public class MyFragmentAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentList= new ArrayList<Fragment>();
private List<String> stringList=new ArrayList<String>();
public MyFragmentAdapter(FragmentManager fm, List<Fragment> fragmentList, List<String> stringList) {
    super(fm);
    this.fragmentList=fragmentList;
    this.stringList =stringList;
    Log.i("CHONG","MyFragmentAdapter construct");
}

@Override
public Fragment getItem(int position) {
    Log.i("CHONG"," getItem");
    return fragmentList.get(position);
}

@Override
public int getCount() {
    Log.i("CHONG"," getItem");
    return fragmentList.size();
}

@Override
public CharSequence getPageTitle(int position) {
    return stringList.get(position);
}

}

Error log:

04-29 09:17:33.651 11798-11798/com.example.administrator.buyer E/JavaBinder:

    !!! FAILED BINDER TRANSACTION !!!

04-29 09:17:33.661 11798-11798/com.example.administrator.buyer                     E/AndroidRuntime: Error reporting crash
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: android.os.TransactionTooLargeException
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime:     at android.os.BinderProxy.transactNative(Native Method)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime:     at android.os.BinderProxy.transact(Binder.java:496)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime:     at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4124)

04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime:     at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:89)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime:     at com.loc.ai.uncaughtException(DynamicExceptionHandler.java:86)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime:     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime:     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)

Thanks in advance!!

Yog
  • 11
  • 3

3 Answers3

1

This exception can be caused when you don't set attachToRoot false in your Fragment class's onCreateView() method while inflating the layout.
If it is true which it is by default, it means 'add the child view to parent RIGHT NOW'
If it is set to false then it means 'add the child view to parent NOT NOW' Adding fragments right away to parent causes this exception.

Saini Arun
  • 391
  • 3
  • 7
0

I think the main problem is having a too large image size in the fragment, therefore the transaction to view the fragment could not complete, however this can be fixed by loading the image independently, you could use a library called Picasso to load an image into the image view using a local/remote resource http://square.github.io/picasso/ for example Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);

reference for the issue: What to do on TransactionTooLargeException

Community
  • 1
  • 1
kareem adel
  • 491
  • 3
  • 8
0

Try clearing the old savedinstance

 @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.clear();
    }

or other way while you inflate your fragment you might be missing last item.

 View view = inflater.inflate(R.layout.activity_news, container, false);

--> Missing the last element? add false in it.