当前位置: 代码迷 >> Android >> IPowerManager移植有关问题
  详细解决方案

IPowerManager移植有关问题

热度:16   发布时间:2016-05-01 21:16:14.0
IPowerManager移植问题
请教各位,我有份代码用到了IPowerManager ,但是在2.1里没有IPowerManager,应该想办法移植还是直接用新的接口。

Java code
    private void setBacklight(int brightness) {        try {            IPowerManager power = IPowerManager.Stub.asInterface(                    ServiceManager.getService("power"));            if (power != null) {                power.setBacklightBrightness(brightness);                Log.i(TAG, "set brightness to :"+ new Integer(brightness).toString());            }        } catch (RemoteException doe) {            Log.e(mName, "can't set backlights");        }            }


------解决方案--------------------
其实编译过,好像权限也不行的,1.5开始有新的设置方法了,
------解决方案--------------------
Is there a way to raise the backlight on an Android device through the official API?
http://stackoverflow.com/questions/826970/is-there-a-way-to-raise-the-backlight-on-an-android-device-through-the-official-a

changing screen brightness
http://www.anddev.org/viewtopic.php?p=12512
------解决方案--------------------
自己编译下android framework,生成个自制的android.jar就行了,权限问题,当然你换更老的,比如0.9的肯定能编译通过
  相关解决方案