This problem was encountered during development. java. Lang. runtimeexception: unable to start activity componentinfo
It is often found that the original is to add
The reason for canceling the title code requestwindowfeature (window. feature_no_title); // cancel the title setcontentview (R. layout. onlinevideo); // The activity style file must be written in the middle
This. getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen,
Windowmanager. layoutparams. flag_fullscreen );
Initbutton ();
Videoview = (videoview) This. findviewbyid (R. Id. rtsp_player );
Videoview. setonerrorlistener (videoerrorlistener );
Videoview. setmediacontroller (New mediacontroller (this ));
Java. Lang. runtimeexception: unable to start activity componentinfo
This is because:
The execution sequence of Android Java is related! This problem occurs because the constructor of the parent class has been called at the beginning of the system running, and the setcontentview method is called to display the View Interface. R. layout. Main is an attribute in the R. Java Resource class. After you call this method, when declaring the widget, the following message is displayed: Android. util. androidruntimeexception: requestfeature () must be called before adding content.
Therefore, the code of the sentence containing the activity style must be written in the middle of the preceding three sentences.