如果方向转变Android应用程序崩溃 [英] Android app crashes if the orientation changes

查看:97
本文介绍了如果方向转变Android应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个游戏程序,我通过一个叫分享按钮分享一些细节到Facebook。当我完成它要求在对话框中的名称的游戏,它表明没有问题,在同一方向(横向/纵向)工作时。如果我打的景观,完成比赛,翻转手机转为纵向来输入我的名字,然后点击共享,它会崩溃。如何克服这个问题?

I have created a game app where I share some details to Facebook through a button called Share. When I finish the game it asks for the name in a dialog box, it shows no problem when working on the same orientation (landscape/portrait). If I'm playing in landscape, finish the game, flip the phone to portrait to type my name in, then click "Share" it will crash. How to overcome this problem?

推荐答案

这是活动重新启动的方向改变时。我猜这重新出现在你的code为不保存所需的信息。您可以通过处理具体配置不停地翻动自己这个默认行为(即:方向变化)。在做这方面的一个很好的教程就设在这里:处理运行时更改

An activity is restarted when the orientation changes. I'm guessing your code isn't saving needed information before this restart occurs. You can stop this default behavior by handling specific configuration changes yourself (ie: orientation change). A good tutorial on doing this is located here: Handling Runtime Changes

这篇关于如果方向转变Android应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆