E/AndroidRuntime( 5751): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.Android/com.example.Android.OpenByApiActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
E/AndroidRuntime( 5751): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
E/AndroidRuntime( 5751): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 5751): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 5751): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 5751): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
Does anybody know why this is being thrown? This is my code for the video and xml
public class OpenByApiActivity extends Activity implements Callback {
MediaPlayer mp = new MediaPlayer();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.video);
StringBuilder log = new StringBuilder();
String[] clearLogcat = new String[] { "logcat", "-c",};
try {
Runtime.getRuntime().exec(clearLogcat);
}
catch (IOException e) {
e.printStackTrace();
}
File location = new File("/sdcard/MediaTestFiles/sample.mp4");
Uri path = Uri.fromFile(location);
SurfaceView surfaceView;
SurfaceHolder surfaceHolder;
getWindow().setFormat(PixelFormat.UNKNOWN);
surfaceView = (SurfaceView)findViewById(R.id.surfaceview);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setFixedSize(176, 144);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.setDisplay(surfaceHolder);
mp= MediaPlayer.create(this, path);
if(mp!=null){
mp.start();
}}}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}}
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<SurfaceView
android:id="@+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>