Is that possible to check was onCreate called because of orientation change?

后端 未结 8 1521
甜味超标
甜味超标 2020-12-06 00:08

I need to act differently in onStart() method depending on how onCreate() was called in result of orientation change or not. Is that

8条回答
  •  情书的邮戳
    2020-12-06 00:52

    You can try the following. On each onStart, you can save the current orientation (take a look here). If it is the first onStart call, do nothing, on other calls, check if the orientation has changed and do what you need.

    private int m_currentOrientation = -1;
    
    public void onStart()
    {
       int oldOrientation = m_currentOrientation; // 
       m_currentOrientation = getCurrentOrientation(); // As in the link above
       if ((oldOrientation != -1) && (oldOrientation != m_currentOrientation))
       {
           // Do what you need
       }
    }
    

提交回复
热议问题