I am developing a simple app in which i am the counting of volume button press 3 times. If counter is equal to three then some action will happen.
My problem is when i press the hardware volume button when phone is locked then onReceive() method of BroadcastReceiver is not called. Its working fine when phone is unlocked.
Is there any way or trick that When i press volume up button in locked mode then my counter increase and vice versa.
I researched on this and conclusion is that Its is not possible.
But I did in some way but its not good approach because It will drain the battery too much.
I start the media player in background with zero volume. Now volume keys start working when even mobile is locked. As example Music app in which volume buttons work even when mobile is locked.
Related
I wrote an app which starts record audio in response to holding volume up button on phone or headphone, I'm doing it inside dispatchKeyEvent method and it's fine
Problem is, I want to do it when the phone is locked in my pocket, I want to just hold my headphone volume button and start recording, How can I do that in Android? How can you do anything in response to user actions when the phone is locked? For example, how can a music player respond to the user pressing play/pause button on headphone? I know that it is possible, but I don't know how...
Is there a simple way to play a sound at certain set intervals that will play even if the phone is locked and in silent mode? In essence it would act as an alarm, but I don't want an activity to come on screen, I simply want a sound played in the background. I plan to make an interface to enable/disable and set the intervals as well.
I have a music player service , using a MediaPlayer set to stream type STREAM_RING. It works fine when i change volume pressing the volume keys as long as the screen is not locked or off. How do i set my service to respond to these keys even in locked screen mode? Thanks.
Based off this question, it looks like it's not possible to capture volume up/down presses when the screen is locked. Android capturing volume up/down key presses in broadcast receiver?
My application requires resource and drains a battery when it is working. So, I want to know the way that user is not available on the phone.
Is there a way to use the built in power save mode on the blackberry to where if the screen dims to suspend the application works active and when the user wakes the device back up with a keypress or trackball movement to resume the application works active?
Thanks in advance.
Is there a way to use the built in
power save mode on the blackberry to
where if the screen dims to suspend
the application works active and when
the user wakes the device back up with
a keypress or trackball movement to
resume the application works active?
This happens automatically, with no code changes required. Unless something is holding a WakeLock, the CPU will turn off sometime after the screen goes dark. The CPU will turn back on when the user presses the power button.
I have an activity that shows up when the phone screen goes to sleep/turns off ie turns black.
For some reason, the phone turns on when the volume buttons or the camera buttons are pressed. By turns on, I mean the screen wakes up or comes back from the black screen state.
I've tried using dispatchKeyEvent(KeyEvent event) and the buttons are disabled on the activity, but they still wake up the phone.
You could try overriding the onKeyDown(KeyEvent) method and change what happens for those keys. However, I'm not too optimistic as if you're running an activity, it will be in an inactive state when the display is off, and also it could be that the phone is hard wired to wake up on those buttons. It could be device specific. Hard to say. Try that out and let me know how it goes, I'm currious