Android exception requestfeature must be called before adding content

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.