Android-7(API24) released a few days ago, download the latest experience of a small inside, of course, is the simulator, to be honest, but it does not have any use. Below is a sneak peek of the small recorded GIFs.

experience

implementation

Split screen, or quite simple, the code layer, of course, the bottom of the implementation has not been studied, but really do not know in this small mobile phone split screen has what use, good nonsense do not say now is a masturbation.

To implement split screens, you just need to define an attribute in androidmanifest.xml, which supports split screens by default


    
    
        
        
    

        Copy the code

Isn’t it easy, as you think, what is the period after this change?

Start the Activity in another split screen

Flag_activity_launch_flags = intent.flag_activity_launch_flags Intent Intent = new Intent(this, adjacentActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);Copy the code

Split screen is not supported

  1. Intent.FLAG_ACTIVITY_NEW_TASK does not support split screen
  2. Set intent. FLAG_ACTIVITY_NEW_TASK to disable the split screen

Split screen change monitor

The new API adds the following back to notify split screen changes

@override public void onMultiWindowModeChanged(Boolean isInMultiWindowMode) { super.onMultiWindowModeChanged(isInMultiWindowMode); Log.i(TAG, "****** onMultiWindowModeChanged() ******"); }Copy the code

Life cycle change

The split screen change of the Activity is still the same as before. It can be regarded as a switch of the Activity.

  1. Long press the menu key (usually fang Kuaijian) to enter the split screen

    com.mz.android_7.MainActivity****** onMultiWindowModeChanged() ****** com.mz.android_7.MainActivity****** onPause() ****** com.mz.android_7.MainActivity****** onStop() ****** com.mz.android_7.MainActivity****** onDestroy() ****** com.mz.android_7.MainActivity****** onCreate() ****** com.mz.android_7.MainActivity****** onStart() ****** com.mz.android_7.MainActivity****** onResume() ****** com.mz.android_7.MainActivity****** onPause() ****** // // The Activity is destroyed and rebuilt, and the current Activity enters the pause state and is no longer in focusCopy the code
  2. Click the current split screen

    Com.mz.android_7.mainactivity ****** onResume() ****** // ResumesCopy the code
  3. Click on another split screen

    Com.mz.android_7.mainactivity ****** onPause() ****** // Enter the pause state again. If no other operation is performed, click back and forth to switch between the two statesCopy the code
  4. Exit the split screen

    com.mz.android_7.MainActivity****** onPause() ****** com.mz.android_7.MainActivity****** onStop() ****** com.mz.android_7.MainActivity****** onDestroy() ****** com.mz.android_7.MainActivity****** onCreate() ****** com.mz.android_7.MainActivity****** onStart() ****** com.mz.android_7.MainActivity****** onResume() ****** Com.mz.android_7.mainactivity ****** onMultiWindowModeChanged() ****** // Activity destroy rebuild, enter resume state, split screen exitCopy the code

conclusion

The split screen of Android 7 doesn’t seem very useful to me, but essentially it improves the user experience, as long as it runs smoothly. The essence of it is that only one Activity is in resume state at any one time, so there is nothing too sophisticated, just understanding the life cycle.