I have found ways to implement it as follows...
code:
public class main extends AppCompatActivity implements View.OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lvl_1);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AppName: tag");
wl.acquire();
wl.release();
}
And then I have also added the permission code for wake lock in manifest. However, it does not work properly, as the screen goes off, when I reopen the screen again, my app closes and some random error occurs.(the error is not related to wakelock, but because of the presence of partial wakelock codes that I have added). Guys, pls help me out. I have been stuck in this issue for almost a week. Thanks in advance, guys.