scheduling alarm for every second in android 5.1

后端 未结 7 2201
醉梦人生
醉梦人生 2020-12-05 20:04


I want to run alarm service for every second in my application.It is working fine below 5.1 version. but it is not triggering in 5.1 devices. I am using commonsware wa

7条回答
  •  醉梦人生
    2020-12-05 20:38

    I've successfully changed the minimum AlarmManager interval from 1 minute to 30 seconds.

    On your device copy /system/framework/services.jar to your computer. Extract classes.dex from it, open with Winrar for example.

     

    Download baksmali

    java -jar baksmali.jar -o extractfolder classes.dex

    edit extractfolder\com\android\server\AlarmManagerService$Constants.smali

    Replace all values 0xea60 (60000ms /1min in hex) to however many ms you want the minimum interval to be example 30seconds 0x7530

    Save and Smali back to classes.dex

    java -Xmx512M -jar smali.jar extractfolder -o classes.dex

    Open services.jar again in Winrar, delete classes.dex and drag the newly created classes.dex into services.jar.

    Copy back to /system/framework/services.jar

    Restart device.

    Also on my Samsung device, having the word alarm OR alert(not tested) in the package name adds it to a whitelist. My alarms are fired exactly when I do this.

提交回复
热议问题