Android removes the title bar and full screen, and sets the android timeout sleep time.

Source: Internet
Author: User
It is easy for Android to remove the title bar and full screen. There are two common methods:

First, implement in the program:
  1. This. requestwindowfeature (window. feature_no_title); // remove the title bar.
  2. This. getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); // remove the Information bar Note: The two lines of code should be written before the page is displayed, that is, setcontentview (R. layout. XXX) before

Second, the Android: Theme tag is implemented in the androidmanifest. xml configuration file.

  1. <Activity Android: Name = "activity1"
  2. Android: theme = "@ Android: style/theme. notitlebar. fullscreen"> </activity>

Note: If you do not need full screen, you only need to write Android: theme = "@ Android: style/theme. notitlebar to OK.

Summary: differences between the two

The first method is to temporarily display the title bar and Information bar when the activity is started, and then disappear. This does not happen in the second method, and it looks smooth.

Modify the timeout sleep time:

By default, the android system does not operate for more than n minutes, and the screen is automatically closed and sleep.
In fact, some projects require timeout and not sleep. If it is only for a single application, we can set the status through power management,

If you want to set the timeout time for all applications, you can refer to the following methods:

 

Method 1: Adjust the Code:

Settings. system. putint (getcontentresolver (), Android. provider. settings. system. screen_off_timeout,-1 );

Permission: <uses-Permission Android: Name = "android. Permission. write_settings"/>

 

Method 2: Adjust the database:

These settings of Android are stored in the SQL database, that is, you can directly modify the database to prevent android from sleep.

Sqlite3/data/COM. Android. providers. Settings/databases/settings. DB

Specific SQL: update system set value = '-1' where name = 'screen _ off_timeout ';

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.