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

以編程方式檢查省電模式

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

問題描述

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

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 應(yīng)該實(shí)現(xiàn)了省電功能(以前 HTC 和三星會(huì)將這些功能自己添加到軟件中).現(xiàn)在大概這意味著谷歌將為其添加某種 API.理想情況下,會(huì)添加一個(gè)新動(dòng)作,以便我可以聽.

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 是否可以實(shí)現(xiàn)上述操作,如果可以,我該如何使用它們.

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

我一直在到處尋找上述問題,但絕對(duì)沒有運(yùn)氣,應(yīng)用程序 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.

編輯:節(jié)電值可以從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 和三星設(shè)備做到這一點(diǎn).兩者都將其電源管理器設(shè)置存儲(chǔ)在 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.

兩者都將布爾值存儲(chǔ)為字符串,0"為假,1"為真.然后,您可以像這樣使用 ContentObserver 監(jiān)聽更改(需要 API 級(jí)別 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 發(fā)布之前,當(dāng) L 發(fā)布時(shí),HTC 和三星可能會(huì)轉(zhuǎn)移到 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.

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

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

相關(guān)文檔推薦

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 存儲(chǔ)桶身份驗(yàn)證錯(cuò)誤)
admob 6.2.1 nullpointer exception(admob 6.2.1 空指針異常)
How to setup SDK in IntelliJ IDEA?(如何在 IntelliJ IDEA 中設(shè)置 SDK?)
My phone cannot be detected in eclipse to test run(eclipse 無法檢測(cè)到我的手機(jī)進(jìn)行試運(yùn)行)
platform-toolsaapt.exe directory missing in android SDK(android SDK 中缺少 platform-toolsaapt.exe 目錄)
主站蜘蛛池模板: 狠狠涩 | 久久久久久久久久久福利观看 | 日韩精品在线看 | 女同av亚洲女人天堂 | 成人免费观看网站 | 欧美三级在线 | 日本精品一区二区三区四区 | 国产一区二区在线免费播放 | caoporon| 精品欧美乱码久久久久久 | 精品欧美一区免费观看α√ | 黄篇网址| 特级特黄特色的免费大片 | 精品久久久久久久久久久久久 | 久久伊人亚洲 | 免费一级做a爰片久久毛片潮喷 | 亚洲一区二区精品视频 | 九九热免费在线观看 | 在线观看免费av网 | 97视频人人澡人人爽 | 色综合久久久久 | 国产精品久久久久一区二区三区 | 一区二区三区精品视频 | 欧美电影免费网站 | 狠狠婷婷综合久久久久久妖精 | 国产区视频在线观看 | 99精品国自产在线 | 国产视频欧美 | 日韩伦理电影免费在线观看 | 欧美一级免费 | 日本在线免费看最新的电影 | 超碰在线国产 | 日韩欧美二区 | 97国产精品| 九九综合 | 亚洲精品乱码久久久久久按摩 | 午夜资源 | 久久出精品 | 欧美日韩中文在线观看 | 激情欧美一区二区三区中文字幕 | 亚洲国产一区视频 |