Android的语境和上下文电源管理 [英] Android Context and context PowerManager

查看:131
本文介绍了Android的语境和上下文电源管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林位于背景上下文收到错误信息。又该何去何从呢?

 电源管理经理=(电源管理)context.getSystemService(Context.POWER_SERVICE);
    激活锁定激活锁定= mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCKMyWakeLock);
    wakeLock.acquire();


解决方案

电源管理经理=(电源管理)context.getSystemService(Context.POWER_SERVICE);

与nameofclass.this替换上下文或使用的getContext()

这将工作

Im getting errors at context and Context. What should go there?

    PowerManager mgr =  (PowerManager)context.getSystemService(Context.POWER_SERVICE);
    WakeLock wakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
    wakeLock.acquire();

解决方案

PowerManager mgr = (PowerManager)context.getSystemService(Context.POWER_SERVICE);

replace Context with nameofclass.this or use getContext()

It will work

这篇关于Android的语境和上下文电源管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆