Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android FULL_WAKE_LOCK is deprecated but PARTIAL_WAKE_LOCK is not deprecated

Here i mentioned the code for waking up the screen. i want the code is listen still the app is closed and the cpu is cleared and user can click the power button when ever my screen is unlock the app is sync like whatsapp.

    PowerManager pm =  (PowerManager)getSystemService(Context.POWER_SERVICE); 
    wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "whatever");
    super.onCreate(savedInstanceState);
    wl.acquire();
like image 421
KOUSIK daniel Avatar asked May 28 '15 10:05

KOUSIK daniel


1 Answers

FULL_WAKE_LOCK is already deprecated and it's better to use the PARTIAL_WAKE_LOCK. This is the standard way to do this,

PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
Wakelock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
        "MyWakelockTag");
wakeLock.acquire();

For more way of implementation kindly visit the official link,

https://developer.android.com/training/scheduling/wakelock.html

like image 85
Prokash Sarkar Avatar answered Oct 03 '22 20:10

Prokash Sarkar