I have already seen the other questions similar to mine, but the problem persists. Thanks in advance.
Here's the code
package com.akk.mysecondvideo;
import android.app.Activity;
import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.VideoView;
public class MySecondVideo extends Activity {
Context context;
MediaPlayer mp;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView)findViewById(R.id.VideoView);
//MediaController mediaController = new MediaController(this);
// mediaController.setAnchorView(videoView);
//videoView.setMediaController(mediaController);
Uri uri = Uri.parse("android.resource://com.akk.mysecondvideo/"
+ R.raw.bommarillu);
videoView.setVideoURI(uri);
//mp = new MediaPlayer();
//mp = MediaPlayer.create(context, R.raw.bommarillu);
videoView.start();
}
}
It shows a force close when i try to run it, and the logcat shows error NULLPOINTEREXCEPTION
in line 28 which is videoView.setVideoURI(uri);
VideoView is part of main.xml. The main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/VideoView" />
</LinearLayout>