How to restart Activity in Android

后端 未结 21 2466
日久生厌
日久生厌 2020-11-22 08:14

How do I restart an Android Activity? I tried the following, but the Activity simply quits.

public static void restartActivity(Act         


        
21条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 08:41

    In conjunction with strange SurfaceView lifecycle behaviour with the Camera. I have found that recreate() does not behave well with the lifecycle of SurfaceViews. surfaceDestroyed isn't ever called during the recreation cycle. It is called after onResume (strange), at which point my SurfaceView is destroyed.

    The original way of recreating an activity works fine.

    Intent intent = getIntent();
    finish();
    startActivity(intent);
    

    I can't figure out exactly why this is, but it is just an observation that can hopefully guide others in the future because it fixed my problems i was having with SurfaceViews

提交回复
热议问题