You should add a contentView
on your activity onCreate
So change your onCreate
Like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout_name) // Add this line,
VideoView videoView=findViewById(R.id.videoView);
String path="android.resource://"+getPackageName()+"/"+R.raw.playthis;
Uri uri=Uri.parse(path);
videoView.setVideoPath(uri.getPath());
}
After that you should check null
video path, like
// If path is not null then set it to your videoView.
if(uri.getPath() != null) {
videoView.setVideoPath(uri.getPath());
}
CLICK HERE to find out more related problems solutions.