0

Iam trying to add a videoview with content from firebase but it's not working. Can anyone tell me what is wrong with this code ? The app iss crashing with this error log :

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.addView(android.view.View)' on a null object reference

Here's the code

       if(dataSnapshot.child("video1").exists()){
                LinearLayout 
linearLayout=findViewById(R.id.linearlayoutmore);

                String 
video=dataSnapshot.child("video1").getValue().toString();

                VideoView vid= new VideoView(entProfileFull.this);
                vid.setVideoURI(Uri.parse(String.valueOf(video)));
                linearLayout.addView(vid);
                ViewGroup.LayoutParams layoutParams=vid.getLayoutParams();
                vid.setLayoutParams(layoutParams);
                MediaController mediaController = new 
MediaController(getApplicationContext());
                vid.setMediaController(mediaController);
                vid.requestFocus();
                vid.seekTo(100);

0 Answers0