如何在应用程序未运行时保持屏幕清醒?(在服务中)
我正在使用此代码,但它不起作用
活动:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = new Intent(MainActivity.this, KeepAliveService.class);
getContext().startService(i);
}
服务:
@Override
public IBinder onBind(Intent intent)
{
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, this.getClass().getName().toString());
wl.acquire();
return null;
}