Why not use always android:configChanges=“keyboardHidden|orientation”?

前端 未结 4 2119
南方客
南方客 2020-11-22 03:28

I was wondering why not use android:configChanges=\"keyboardHidden|orientation\" in every (almost every ;)) activity?

Goods:

4条回答
  •  耶瑟儿~
    2020-11-22 04:25

    Yeah I think pausing will make it quicker than releasing the player. Still have the pause though.

    Have now found a solution that won't pause the song.

    State in the manifest that you will handle the config change for screen orientation and then use the onConfigurationChanged method to load the layout file. By doing this in logCat I can see onPause, onCreate & onResume aren't called, and therefore the song isn't paused.

    1. update the manifest to handle the orientation.

      android:configChanges="orientation|screenSize"
      
    2. add this code

      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          // TODO Auto-generated method stub      
          super.onConfigurationChanged(newConfig);        
          setContentView(R.layout.activity_main);
      }
      

提交回复
热议问题