There are some situations where the phone should be prevented from going to sleep mode or screen lock mode. Eg. while watching a webpage/video or some presentations.
PowerManager pman = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wlock = pman.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
//screen will stay on during this section..
//Do the tasks here
<uses-permission android:name="android.permission.WAKE_LOCK" />
This is a resource intensive call. It uses a considerable amount of battery and processing power. Hence usage should be minimized or avoided if possible.