I'm inflating layout with VideoView into ViewPager.
Here is code in instantiateItem
function:
RelativeLayout v = (RelativeLayout) li.inflate(R.layout.background34, null);
vv = (VideoView)v.findViewById(R.id.videoView);
Uri video = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.advetime);
MediaController mc = new MediaController(context);
mc.setAnchorView(vv);
mc.setMediaPlayer(vv);
vv.setMediaController(mc);
mc.show(0);
vv.setVideoURI(video);
vv.start();
my app crashes at line mc.show(0)
with error:
E/AndroidRuntime(24284): FATAL EXCEPTION: main
E/AndroidRuntime(24284): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
What is the problem? Help me please.