I want the sound to play in my app when the screen times out or the user presses the power button to cut the screen off.
@Override
public void onCreate(Bundle savedInstanceState) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"Wake lock");
wl.acquire();
super.onCreate(savedInstanceState);
setContentView(R.layout.paint);
}
This is the onCreate for my activity. Below this there is a onClick switch statement listening for a button to be clicked and when the button is clicked it plays a sound. It doesnt launch a new activity, just plays the sound. The sound stops when the user hits the power button or the screen timese out and that isnt what I want. I want it to play when the user locks the screen or a timeout happens. I also did recheck the manifest and it has the proper permission.