我是android开发中的新手,我正在制作一个应用程序来显示不同类型的video.i有一个导航drawer,其中包含不同类型的选项,名为favorite video.when I点击我最喜欢的视频导航抽屉我试图展示我最喜欢的视频时出现意外错误。 下面是收到的logcat的消息:在导航抽屉选项菜单上获取url string null
12-20 05:13:06.062: E/AndroidRuntime(1039): FATAL EXCEPTION: main
12-20 05:13:06.062: E/AndroidRuntime(1039): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dsnl.omygod/com.ebizzinfotech.MenuFragments.CustomPlayer}: java.lang.NullPointerException: uriString
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.os.Looper.loop(Looper.java:137)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-20 05:13:06.062: E/AndroidRuntime(1039): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 05:13:06.062: E/AndroidRuntime(1039): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 05:13:06.062: E/AndroidRuntime(1039): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-20 05:13:06.062: E/AndroidRuntime(1039): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-20 05:13:06.062: E/AndroidRuntime(1039): at dalvik.system.NativeStart.main(Native Method)
12-20 05:13:06.062: E/AndroidRuntime(1039): Caused by: java.lang.NullPointerException: uriString
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.net.Uri$StringUri.<init>(Uri.java:464)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.net.Uri$StringUri.<init>(Uri.java:454)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.net.Uri.parse(Uri.java:426)
12-20 05:13:06.062: E/AndroidRuntime(1039): at com.ebizzinfotech.MenuFragments.CustomPlayer.onCreate(CustomPlayer.java:58)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.Activity.performCreate(Activity.java:5008)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-20 05:13:06.062: E/AndroidRuntime(1039): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-20 05:13:06.062: E/AndroidRuntime(1039): ... 11 more
下面是活动的代码。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player);
Bundle b = getIntent().getExtras();
VIDEO_ID = b.getString("VIDEO_URL");
//Log.i("video id print",VIDEO_ID);
loading = (ProgressBar) findViewById(R.id.loading);
stop = (Button) findViewById(R.id.stop);
playtogglebutton = (ToggleButton) findViewById(R.id.playtogglebutton);
timeElapsed = (TextView) findViewById(R.id.timeElapsed);
timeEnd = (TextView) findViewById(R.id.timeEnd);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
videoviewer = (VideoView) findViewById(R.id.videoviewer);
videoviewer.setVideoURI(Uri.parse(VIDEO_ID));
videoviewer.requestFocus();
videoviewer.setKeepScreenOn(true);
videoviewer.setOnErrorListener(this);
videoviewer.setOnPreparedListener(this);
}
是的,我正在使用互联网许可 –