http://developer.android.com/guide/topics/resources/runtime-changes.html You can see the link under the heading Processing configuration changes.
<activity android:name=".MyActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name">
Now that one of these configurations changes, MyActivity does not restart. Instead, MyActivity receives an onConfigurationChanged () call. This method is passed to the Configuration object, which defines the new device configuration.
android:configChanges="orientation|screenSize" (andorid 3.2 and above screen size also changes. add this)
Suppose your video is 10 minutes. The video plays up to 5 minutes and the orientation changes, you know that he played up to 5 minutes.
You can save the actual video progress in onSaveInstanceState () and get the saved data in onRestoreInstanceState () from the Bundle, after which you can start the game with either progress data, or from the very beginning if there was no saved data.
When the activity of a change in orientation is destroyed and recreated. If you want to save data and save, you can do as below to save a large data set.
@Override public Object onRetainNonConfigurationInstance() { final MyDataObject data = collectMyLoadedData(); return data; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final MyDataObject data = (MyDataObject) getLastNonConfigurationInstance(); if (data == null) { data = loadMyData(); } }
For a small data set
@Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); // Save UI state changes to the savedInstanceState. // This bundle will be passed to onCreate if the process is // killed and restarted. savedInstanceState.putString("NICK_NAME", Name);//save nick name } @Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); // Restore UI state from the savedInstanceState. // This bundle has also been passed to onCreate. Name = savedInstanceState.getString("NICK_NAME");//restore nick name }
To check the orientation
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show(); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){ Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show(); } }
VideoView on Android . In this case, the video is also transmitted from the server. Check the accepted answer (answer to the community call). Similarly, I suggested.