Disable Android StatusBar drop-down

Source: Internet
Author: User

There are many hidden services in Android, and StatusBarManager is one of them, which can be seen in Context. java:


[Java]
/**
* Use with {@ link # getSystemService} to retrieve a {@ link
* Android. app. StatusBarManager} for interacting with the status bar.
*
* @ See # getSystemService
* @ See android. app. StatusBarManager
* @ Hide
*/
Public static final String STATUS_BAR_SERVICE = "statusbar ";

/**
* Use with {@ link # getSystemService} to retrieve a {@ link
* Android. app. StatusBarManager} for interacting with the status bar.
*
* @ See # getSystemService
* @ See android. app. StatusBarManager
* @ Hide
*/
Public static final String STATUS_BAR_SERVICE = "statusbar ";

 

This indicates that the service is not provided externally. If you want to call the service, you must compile it in the source code tree to call the interface marked as @ hide. You can also add the compiled classes. jar package to the project.

 


StatusBarManager provides some useful interfaces. For example, the disable () method is exactly what we need. Some system-level applications call this method to disable the StatusBar drop-down, such as the phone number and lock screen module. To call this method, you also need the following permissions:


[Html]
<Uses-permission android: name = "android. permission. STATUS_BAR"/>
<Uses-permission android: name = "android. permission. EXPAND_STATUS_BAR"/>

<Uses-permission android: name = "android. permission. STATUS_BAR"/>
<Uses-permission android: name = "android. permission. EXPAND_STATUS_BAR"/>


Get StatusBarManager instance,

 

[Java]
MStatusBarManager = (StatusBarManager) mContext. getSystemService (Context. STATUS_BAR_SERVICE );

MStatusBarManager = (StatusBarManager) mContext. getSystemService (Context. STATUS_BAR_SERVICE );
Drop-down prohibited,


[Java]
MStatusBarManager. disable (StatusBarManager. DISABLE_EXPAND );

MStatusBarManager. disable (StatusBarManager. DISABLE_EXPAND );
Revoke prohibition,


[Java]
MStatusBarManager. disable (StatusBarManager. DISABLE_NONE );

MStatusBarManager. disable (StatusBarManager. DISABLE_NONE );

 

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.