生命周期再研究
onResume和onPause肯定是会触发的,start和stop如果是后台的time 稍微长一点,就会触发,并且带有restart。
这篇文章里说到了。再honeycomb之前,saveinstancestate是在pause后调用的,在pie之后就在stop之后调用的
https://developer.android.com/reference/android/app/Activity
这也是为社么我调试了好久,发现这个问题。还以为虚拟机的问题,到手机里测试还是一样。文章中建议,在onstop那里保存变量。但是我测试了onstop那里获取不到videoView.getCurrentPosition(),但是在onpause里有数据。所以还是onPause和onResume靠谱。
alertdialog的button类型研究
positivebutton和negtive是在对话框的最右边,neutral是在最左边。并且不影响activity的生命周期。
最合适videoview的layout
android:id="@+id/videoView"
android:layout_width=“match_parent”
android:layout_height=“match_parent”
app:layout_constraintBottom_toBottomOf=“parent”
app:layout_constraintEnd_toEndOf=“parent”
app:layout_constraintStart_toStartOf=“parent”
app:layout_constraintTop_toTopOf=“parent”
app:layout_constraintDimensionRatio=“1:1”
并且constraintLayout是最合适的。