简体   繁体   English

应用程序可能在其主线程消息上做过多的工作

[英]the application may be doing too much work on its main thread message

Am developing an android app where am using multiple fragments in its UI for different purposes 我正在开发一个Android应用程序,其中在其UI中出于不同目的使用多个片段

like, I have 4 fragments below which gets executed onCreate() 像,我下面有4个片段,它们在onCreate()上执行

android.support.v4.app.FragmentManager on = getSupportFragmentManager();
FragmentTransaction on = on.beginTransaction();
onTransaction.replace(R.id.fragment_on, new On());
onTransaction.commit();

android.support.v4.app.FragmentManager tw = getSupportFragmentManager();
FragmentTransaction twTransaction = tw.beginTransaction();
twTransaction.replace(R.id.fragment_tw, new TW());
twTransaction.commit();

android.support.v4.app.FragmentManager th = getSupportFragmentManager();
FragmentTransaction thTransaction = th.beginTransaction();
thTransaction.replace(R.id.th, new TH());
th.commit();

android.support.v4.app.FragmentManager fo = getSupportFragmentManager();
FragmentTransaction foTransaction = gfo.beginTransaction();
foTransaction.replace(R.id.fragment_fo, new Fo());
foTransaction.commit();

but, am getting these messages in logcat 但是,正在logcat中获取这些消息

I/Choreographer﹕ Skipped 30 frames!  The application may be doing too much work on its main thread.

I/dalvikvm-heap﹕ Grow heap (frag case) to 22.032MB for 348072-byte allocation

though these doesn't have any effect on the performance of the app but i fear these might lead to force closing of the app in low end devices. 尽管这些对应用程序的性能没有任何影响,但我担心它们可能会导致在低端设备中强制关闭应用程序。 (As per my tests app becomes bit slow in low end devices, which is not a good sign) (根据我的测试应用程序,在低端设备中会变慢,这不是一个好兆头)

Is there any better way to populate multiple fragments? 有没有更好的方法来填充多个片段? if so , please guide me how to do this 如果是这样,请指导我如何执行此操作

Add android:largeHeap="true" this manifest and Go for async task . 添加清单清单android:largeHeap =“ true”并执行异步任务 Don't Go for main thread. 不要去找主线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM