Android: Increase call stack size

我们两清 提交于 2019-11-27 14:45:50

You might not be able to increase call stack size in the main UI Thread(which is understandable because you're supposed to do as few things as possible here), but you can do it in a separate thread by making use of the Thread object's constructor parameters:

ThreadGroup group = new ThreadGroup("threadGroup");
new Thread(group, runnableObject, "YourThreadName", 2000000).start();

With this example I increased my stack size from 8k (around 260 calls) to 2M (enough for not to get the StackOverFlowException, of course you can add as much as you want as long as the memory can take it), so in the end, for further readers, this is the way you can increase your stack size,although is not recommended, in some cases it's actually necessary for example an algorithm with extensive recursive calls and of course by doing all the hard work in a worker thread(as you're supposed to) with your specified stack size and just "posting" changes in UIs using the main UI Thread with Handlers or whatever mechanism you would like to use to interact with it...

Hope this Helps...

Regards!

You definitely don't want to nest layouts inside each other like that. If you find yourself nesting three or four times then the construction of the view becomes less and less efficient, which can cause activity transitions to start and probably in your case finish before the view is created. Which will look weird, or be a complete waste of an activity transition.

You should make your root layout a relative layout and have all your frame layouts as children of that root relative layout.

If you need this complex layout (as many will doubt) you can still draw it programticaly in onCreate method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!