Android Programming for screen-stop hibernation _android

Source: Internet
Author: User

This article illustrates the way that Android programming implements a screen-forbidden hibernation. Share to everyone for your reference, specific as follows:

There are two ways to implement this function, one is in the manifest.xml file declaration, one is in the code to modify the Layoutparams logo bit. Specifically as follows:

1, in the Manifest.xml file with user-permission declaration. the code is as follows:

<uses-permission android:name= "Android.permission.WAKE_LOCK" >
</uses-permission>

This way, when installing APK, the system prompts the installer whether to allow the use of the Disable Hibernate feature.

PS: About Manifest.xml more properties and functions, can refer to the site online tools:

Android manifest Features and Permissions description Encyclopedia:
Http://tools.jb51.net/table/AndroidManifest

2, in the program to achieve the code. the code is as follows:

Copy Code code as follows:
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_ SCREEN_ON);

Add this code to the following:

Setcontentview (R.layout.main)

Before you can.

This method, when installed, does not prompt the installer to allow the use of the Disable Hibernate feature

For more information on Android-related content readers can view the site: "Android View tips Summary", "Android Layout Layout Skills Summary", "Android Development introduction and Advanced Course", " Android Debugging tips and FAQ Solutions Summary, Android Multimedia tips summary (audio, video, audio, etc.), "Android Basic Components Usage Summary" and "Android Control usage Summary"

I hope this article will help you with the Android program.

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.