5

I use activity with ImageView, and by click on button it switches to activity with VideoWiew and plays movie, the movies first frame is the image on previous activity. I disabled animation between activity by using

Intent intent = new Intent(ImageClass.this, MovieClass.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);

but it still flashes black screen between them, how can i disable this?

DanM
  • 1,530
  • 4
  • 23
  • 44
  • look at this answer , this solved my problem, where i was sure i had no heavy work in onCreate() : http://stackoverflow.com/a/16368137/1956013 – Ahmed Adel Ismail Oct 05 '15 at 14:28

2 Answers2

13

One of the simplest way is to move all the expensive (time-consuming) processing from your activity's onCreate and onStart method to onResume mthod. By this, your newly launched activity will be visible right after its launched but then will take a little extra to make it available for user to interact. Further, I would suggest you to move all the heavy lifting in AsyncTask for smoother UI experience.

waqaslam
  • 67,549
  • 16
  • 165
  • 178
0

I recently had a problem with smooth transition. Even though I am loading the lengthy tasks in AsyncTask, it still takes time to load, and the screen has to wait.

If you have a WebView, for example, that takes a while to load, and under the WebView, you have some TextViews and other things, supposedly a layout. The layout will load first, and the WebView later, making the screen loading ackward.

A solution for this would be to set the Visibility to GONE on all the objects before it loads, and then set to VISIBLE after the WebView loads.

webView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {

            webView.setVisibility(View.VISIBLE);
            LinearLayout ll_load_after_web_view_bottom = findViewById(R.id.ll_load_after_web_view_bottom);
            LinearLayout ll_load_after_web_view_top = findViewById(R.id.ll_load_after_web_view_top);
            ll_load_after_web_view_bottom.setVisibility(View.VISIBLE);
            ll_load_after_web_view_top.setVisibility(View.VISIBLE);
        }
    });
live-love
  • 48,840
  • 22
  • 240
  • 204