You can try this link to handle your apps idle time
Application idle time
and in (taken from that answer)
public class ControlApplication extends Application{
private static final String TAG=ControlApplication.class.getName();
private Waiter waiter; //Thread which controls idle time
// only lazy initializations here!
@Override
public void onCreate(){
super.onCreate();
Log.d(TAG, "Starting application"+this.toString());
waiter=new Waiter(15*60*1000); //15 mins
waiter.start();
setContentView(R.layout.blackscreen);
}
public void touch(){
waiter.touch();
}
}
you can call an xml file which has background as black using
EDIT
blackscreen.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context=".MainActivity">