I want to lock my application when it goes in background and when it resumes I want to display my own lock screen. The lock screen is an Activity of my application.
Aft
Well you should override methods onResume and onPause
see this and you will get it :)
in your activity you can have a flag like boolean locked;
and in onPause you can set this to true. And every time in critical places you can check the state of this flag and if it is true then you show you unlock activity, after a success in unlocking then set the flag to false.