My app need to play music whenever user want even in screen off mode. I know 2 ways to do it: - Use a fake MediaPlayer with volume = 0 to listening to volume button. - Use accelerometer to dectect shake.
so, which one drains more battery? which one i should choose? Is there any other way? Thanks for ur helps
The accelerometer will be more battery intensive. If nothing else is using it, it will need to be turned on which costs power. If something is using it, you'll be receiving regular updates which will take more CPU power to process than a single message when a button is actually pushed.