久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

以編程方式檢查省電模式

Checking for Power Saver Mode programmatically(以編程方式檢查省電模式)
本文介紹了以編程方式檢查省電模式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我已經編寫了一個應用程序 (AutoWifiSwitch),并且我計劃添加的功能之一是如果啟用了省電模式,則自動禁用我的應用程序中的 wifi 掃描服務.

I have written an app (AutoWifiSwitch) and one of the features I plan to add is automatically disabling the wifi scanning service in my app if power saving mode is enabled.

我知道 Android L 應該實現了省電功能(以前 HTC 和三星會將這些功能自己添加到軟件中).現在大概這意味著谷歌將為其添加某種 API.理想情況下,會添加一個新動作,以便我可以聽.

I know Android L is supposed to have Battery Saving implemented (previously HTC and Samsung would add the features themselves to the software). Presumably this now means Google will have added some sort of API for it. Ideally there would be a new action added so I could listen for that.

我還想知道 HTC/Samsung API 是否可以實現上述操作,如果可以,我該如何使用它們.

I would also like to know if the above is possible with HTC/Samsung APIs and if so, how do I use them.

我一直在到處尋找上述問題,但絕對沒有運氣,應用程序 SecureSettings(Tasker 的插件)能夠連接到 HTC/Samsung API 以啟用省電模式,我不太懂確定他們是如何做到的.

I've been searching everywhere for the above questions but had absolutely no luck, the app SecureSettings (an addon for Tasker) is able to hook into the HTC/Samsung APIs to enable the power saver anyway, I'm not quite sure how they do it.

編輯:節電值可以從Android L中的PowerManager獲取,但不確定是否有Action.

Edit: The power saver value can be gotten from the PowerManager in Android L, not sure if there is an Action for it though.

推薦答案

我最終想出了如何用 HTC 和三星設備做到這一點.兩者都將其電源管理器設置存儲在 Settings.System 中.

I've eventually figured out how to do this with HTC and Samsung devices. Both store their power manager settings in Settings.System.

HTC (Sense) 使用密鑰 user_powersaver_enable.三星 (Touchwiz) 使用 psm_switch 鍵.

HTC (Sense) uses the key user_powersaver_enable. Samsung (Touchwiz) uses the key psm_switch.

兩者都將布爾值存儲為字符串,0"為假,1"為真.然后,您可以像這樣使用 ContentObserver 監聽更改(需要 API 級別 16 或更高):

Both store the boolean as a String, "0" being false and "1" being true. You can then listen for changes using a ContentObserver like so (requires API level 16 or higher):

getContentResolver().registerContentObserver(Settings.System.CONTENT_URI, true, new ContentObserver(){
  @Override
  public void onChange(boolean selfChange, Uri uri){
    super.onChange(selfChange, uri);
    String key = uri.getPath();
    key = key.substring(key.lastIndexOf("/") + 1, key.length());

    if (key.equals("user_powersaver_enable") || key.equals("psm_switch")){
      boolean batterySaverEnabled = Settings.System.getString(getContentResolver(), key).equals("1");
      // do something
    }
  }
});

但這僅適用于 Android L 發布之前,當 L 發布時,HTC 和三星可能會轉移到 AOSP 省電模式,這意味著您將能夠在 L 中使用新的省電模式 api.

However this will only be applicable until Android L is release, when L is released HTC and Samsung will likely move over to the AOSP battery saver which means you will be able to use the new battery saver api in L.

這篇關于以編程方式檢查省電模式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why would you choose Android API over Google APIs in the SDK on Eclipse?(為什么在 Eclipse 的 SDK 中選擇 Android API 而不是 Google API?)
Couchbase Bucket authentication error(Couchbase 存儲桶身份驗證錯誤)
admob 6.2.1 nullpointer exception(admob 6.2.1 空指針異常)
How to setup SDK in IntelliJ IDEA?(如何在 IntelliJ IDEA 中設置 SDK?)
My phone cannot be detected in eclipse to test run(eclipse 無法檢測到我的手機進行試運行)
platform-toolsaapt.exe directory missing in android SDK(android SDK 中缺少 platform-toolsaapt.exe 目錄)
主站蜘蛛池模板: 国产精品九九九 | 国产欧美精品 | 99视频在线免费观看 | 久久久久久国产精品 | 国产免费又黄又爽又刺激蜜月al | 久久久久久成人 | 日韩一区二区三区在线 | 成年人免费看 | 亚洲综合在线视频 | 久久影院一区 | 欧洲性生活视频 | 国产一区精品 | 亚洲精品一区二区网址 | 中文字幕av在线一二三区 | 精品91久久| www.久| 国产美女视频黄a视频免费 国产精品福利视频 | 精品国产一区二区三区久久久久久 | 天堂亚洲网 | 亚洲国产专区 | 99久久婷婷国产综合精品电影 | 日韩精品中文字幕在线 | 久久精品亚洲欧美日韩久久 | aaaa日韩| 久久久久中文字幕 | 一区二区三区免费 | 九一视频在线观看 | 久久国产精品一区二区三区 | 国产三区在线观看视频 | www.婷婷 | 国产久视频| v亚洲 | 免费黄色网址视频 | 99免费在线观看 | 国产精品成人一区二区 | 一区二区日韩 | 欧美视频一区二区三区 | 欧美成人一级视频 | 在线日韩欧美 | 人人cao| 久操伊人 |