开发者

Android, locking screen and handling rotation

I am making a very simple game (in the hope of learning a bit mor of Android programming as well as doing something functional) and will be locking the screen so its always in landscape mode to play the game.

I have around 5 background threads running (timers, game playing time, level time etc) via asyncTask.

According to my book i still have to have something like task=(RotationAwareTask)getLastNonConfigurationInstance();

and

public Object onRetai开发者_运维技巧nNonConfigurationInstance() { 
    task.detach(); 

    return(task); 
  }

to save the state in case for example a phone call comes in... and a child static class (RotationAwareTask)

This is pretty confusing in the book, is there a simple example that any of you guys are aware of (link to some site)? Or some set of "standard" code that you guys keep reusing that is easier to understand? Just as an example...

Thanks!


The easiest way to do this is set android:screenOrientation attribute in your manifest element instead.

How is application orientation (landscape or portrait) locked?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜