开发者

Android app crashes if the orientation changes

开发者 https://www.devze.com 2023-02-15 21:24 出处:网络
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 sam

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消