I'm attempting to make my ViewPager bounce a few times on first load to indicate to the user that what they are looking at is a horizontally scrollable view. I've tried to use fakeDragBy but my app will crash when I attempt to do this. What is the recommended way to use fakeDragBy properly to achieve what I am seeking?
Here is the code I am running inside my Activity:
#Override
public void onStart(){
super.onStart();
mViewPager.setCurrentItem(0);
mViewPager.beginFakeDrag();
mViewPager.fakeDragBy(25);
mViewPager.endFakeDrag();
}
Here is the stack trace:
09-24 12:21:49.702 28243-28243/com.company E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.company, PID: 28243
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company/com.company.onboarding.OnboardingActivity}: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.support.v4.view.ViewPager.fakeDragBy(ViewPager.java:2431)
at com.company.onboarding.OnboardingActivity.onStart(OnboardingActivity.java:100)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
at android.app.Activity.performStart(Activity.java:5949)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
If you pay close attention to the error log:
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.support.v4.view.ViewPager.fakeDragBy(ViewPager.java:2431)
Your view pager has zero items at the time of the fakeDragBy. That means that the Adapter is not giving your view pager any data, so the ViewPager is not ready to do anything.
We'd need to see how/when you are initializing your ViewPager. Without those bits of information, it's impossible to tell why you're getting an Out of Bounds exception.
Please add more code.
The issue could be else where, it's hard to tell, since you seem to be able to setCurrentItem(0) without problems.
As a side note, the Google's recommendation of wiggling the view pager upon startup to help discovery, mentions that this should only be done once. Since you're adding code to onStart() I guess you intend to do it every time you start the Activity, careful with that ;)
Related
2022-02-01 12:01:30.862 16616-16616/? E/ActivityThread: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ChooserActivity$1#efec398 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ChooserActivity$1#efec398 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.(LoadedApk.java:1607)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1378)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1624)
at android.app.ContextImpl.registerReceiverAsUser(ContextImpl.java:1611)
at android.content.ContextWrapper.registerReceiverAsUser(ContextWrapper.java:720)
at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:98)
at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:86)
at com.android.internal.app.ResolverActivity.onCreate(ResolverActivity.java:523)
at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:828)
at android.app.Activity.performCreate(Activity.java:8127)
at android.app.Activity.performCreate(Activity.java:8098)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3513)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3700)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8061)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
2022-02-01 12:01:30.871 714-721/? E/statsd: Predicate 5980654721335871649 dropping data for dimension key (10)0x2010101->10036[I] (10)0x30000->launch[S]
2022-02-01 12:01:30.897 18012-18012/com.athermobileapp E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1250432)
2022-02-01 12:01:30.923 18012-18012/com.athermobileapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.athermobileapp, PID: 18012
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1250432 bytes
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8061)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Caused by: android.os.TransactionTooLargeException: data parcel size 1250432 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:593)
at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4647)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8061)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
You aren't running out of memory, so calling gc won't help (its also not reliable, and not necessary as Java will run gc if it needs to). Your problem is you're sending an intent that is too big. See the part of the crash that says android.os.TransactionTooLargeException: data parcel size 1250432 bytes? An intent's data can be a maximum of 1 MB. You're at about 1.2 MB. You need to decrease the amount of data in your intent.
In my application, I am facing a weird issue. And this happens only on Android 6. It doesn't crash on version higher than 6.0
I cannot add code because I have no idea where exactly is the crash.
Is there any way to find out what can be an issue. All I have is a full stack trace.
I think this due change in behaviour of ListView in Android 6, but cannot exactly sure about it.
Fatal Exception: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
at android.widget.ListView.dispatchDraw(ListView.java:3327)
at android.view.View.draw(View.java:16276)
at android.widget.AbsListView.draw(AbsListView.java:4316)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1379)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.draw(View.java:16276)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.draw(View.java:16276)
at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2740)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:295)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:301)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:336)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2760)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2564)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2164)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1174)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6241)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873)
at android.view.Choreographer.doCallbacks(Choreographer.java:676)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
I found a scenario which solved my issue.
I had a list which had its own data.
One option was to refresh list. So here, cleared ArrayList >> get new data from API (2-3 secs delay) >> added to ArrayList >> Notify dataset changed.
The problem was I didn't notify dataset immediately after clearing the ArrayList. (Because it would flicker)
Solution: I managed to clear data, add new data and notify at the same time (After API call).
Still wondering why did it only crashed on Android 6.0
I am having a TransactionTooLargeException when I close/minimize my app. I am assuming it is due to my Bundle being too large (3 JSONArrays as strings), but it would be great if someone can diagnose more information from my error trace.
Here it is:
05-28 17:17:25.994 9518-9518/com.adamtrudeauarcaro.godbuilder E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 551100)
05-28 17:17:25.996 9518-9518/com.adamtrudeauarcaro.godbuilder D/AndroidRuntime: Shutting down VM
05-28 17:17:25.998 9518-9518/com.adamtrudeauarcaro.godbuilder E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.package.godbuilder, PID: 9518
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 551100 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4211)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: android.os.TransactionTooLargeException: data parcel size 551100 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:628)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:4132)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4203)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
From your error trace it doesn't say, but I can tell you from experience certainly that this happens when your bundle is too large to store it as a saved instance state. Which means that when you minimize the app, it tries to call onSaveInstanceState and your bundle is storing more data than the supported by the system.
I encountered this exception before too. The scenario is we pass paths of all pictures or videos in album through Bundle to preview fragment, usually it is OK, but it becomes a problem when there are thousands of files in user's device. The exception will be thrown when activity stops and application is reclaimed by system, during which the argument data are passed to system through binder for restore later. Here is the exception trace:
Thread Name: 'main'
Back traces starts.
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 2352912 bytes
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:263)
at android.app.ActivityThread.main(ActivityThread.java:8246)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
Caused by: android.os.TransactionTooLargeException: data parcel size 2352912 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:568)
at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4429)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
... 7 more
Back traces ends.
To fix it, we restraint only one hundred paths around the current clicked picture or video. Here are the codes.
val selections = ArrayList<Selection>()
// The number of pictures in user device can be more than 1000.
// Restrict the list size to fix TransactionTooLargeException: data parcel size too large.
val interval = 100
val start: Int = max(0, position - interval / 2)
val end: Int = min(materials.size - 1, start + interval)
for (i in start..end) {
val albumItem: IAlbumItem = materials[i]
val selection = Selection(Triple("null", i, -1), Pair(-1, -1), albumItem)
selection.what = what
selections.add(selection)
}
val bundle = Bundle()
// The collection has changed, the position should offset the same too.
bundle.putLong("limitVideoDuration", limitVideoDuration)
bundle.putInt("position", position - start)
bundle.putSerializable("selections", selections)
we recently switched to using AppCompatActivity instead of FragmentActivity and now some devices are randomly crashing with the following error. No idea why this is happening.
Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 16008012 byte allocation with 4277152 free bytes and 4MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:856)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:675)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:703)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:733)
at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:779)
at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:741)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:2549)
at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:254)
at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:164)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:2549)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:2320)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:4210)
at android.content.res.Resources.loadDrawable(Resources.java:4089)
at android.content.res.Resources.getDrawable(Resources.java:2005)
at android.content.res.Resources.getDrawable(Resources.java:1987)
at android.content.Context.getDrawable(Context.java:464)
at android.support.v4.content.ContextCompat.android.support.v4.content.ContextCompatApi21.getDrawable(SourceFile:3026)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(SourceFile:200)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(SourceFile:81)
at android.support.v7.app.AppCompatDelegateImplBase.(SourceFile:127)
at android.support.v7.app.AppCompatDelegateImplV9.(SourceFile:147)
at android.support.v7.app.AppCompatDelegateImplV11.(SourceFile:27)
at android.support.v7.app.AppCompatDelegateImplV14.(SourceFile:53)
at android.support.v7.app.AppCompatDelegateImplV23.(SourceFile:29)
at android.support.v7.app.AppCompatDelegate.create(SourceFile:203)
at android.support.v7.app.AppCompatDelegate.create(SourceFile:185)
at android.support.v7.app.AppCompatActivity.getDelegate(SourceFile:525)
at android.support.v7.app.AppCompatActivity.onCreate(SourceFile:74)
at com.dubizzle.horizontal.activities.AbstractActivity.onCreate(SourceFile:98)
at com.dubizzle.horizontal.activities.ItemPhotoViewer.onCreate(SourceFile:68)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
You are trying to load an image using the BitmapFactory right?
I assume that your image is too big:
16008012 byte allocation with 4277152 free bytes and 4MB until OOM
Your image is 16008012 but you only have 4277152 bytes free.
Try using a smaller image.
This happened to me when I set a rather large drawable as the windowBackground property of the activity's theme. Reducing the size of the image should fix it
I get error when I use StaticLayout for create pagination of large text (~6mb).
This is my log:
java.lang.OutOfMemoryError
at android.text.MeasuredText.addStyleRun(MeasuredText.java:193)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:269)
at android.text.StaticLayout.generate(StaticLayout.java:291)
at android.text.StaticLayout.<init>(StaticLayout.java:143)
at android.text.StaticLayout.<init>(StaticLayout.java:93)
at android.text.StaticLayout.<init>(StaticLayout.java:71)
at android.text.StaticLayout.<init>(StaticLayout.java:51)
at com.ex.test.pagenation.Pagination.layout(Pagination.java:38)
at com.ex.test.pagenation.Pagination.<init>(Pagination.java:34)
at com.ex.test.pagenation.MainActivity$1.onGlobalLayout(MainActivity.java:51)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:847)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2006)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Is there any suggestion for fix this error? Or Is there any alternative solution?
You should rewrite or extend Pagination class.
You should not put all the text into StaticLayout at once.
Instead, you should split text into parts. Parts should not be too lage.
I guess 10k-100k will be ok.
take first part, split it into pages, count pages, multiply it by amount of parts - that will be approximate quantity of pages in you book.
When a user want to see the past page of a first part, you should start second part just where the last page of first part begins. And so on.
Do not load all the text into StaticLayout - it is too much.