Android Question Media Button Question in Lollipop 5.0.1

Chris Williams

Member
Licensed User
I just updated my phone to Android Lollipop 5.0.1...my app worked when it was Kitkat 4.4.2. Now it does not respond to my media button click event (when screen is locked). Is there a different way to check if screen is locked and/or determine if volume media button is pressed in 5.0.1? Also the contact manager seems to invert the phone type and number (thats an easy workaround)
 

Chris Williams

Member
Licensed User
UPDATE::: After a series of checks I found that: The intent works if the screen is UNLOCKED. The check for screen lock also works (if it is locked or not). My conclusion is: The intent will not work if the screen is LOCKED (the phone screen is lit, but screen is locked). It seems to ignore the intent or the intent is not active upon screen lock. ANY help or suggestions will be greatly appreciated. I have already accepted defeat (IF there is nothing that can be done about this). ALSO I have noticed that when you press the power button, ONLY power options are available. The option to MUTE, VIBRATE or RING are no longer there. Perhaps this issue is a side-effect...
 

Chris Williams

Member
Licensed User
UPDATE UPDATE:::I now notice that if I am on the phone, or listening to music, the volume button function works as expected when screen lock is active...
 

Erel

Administrator
Staff member
Licensed User
There is a new API in Android 5.0: http://stackoverflow.com/questions/...ation-not-working-after-update-to-android-5-0

Try it with this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   Dim jo As JavaObject
   jo.InitializeContext
   jo.RunMethod("SetSession", Null)
End Sub

#If JAVA
import android.media.session.*;
private static MediaSession ms;
public void SetSession() {
   if (ms == null) {
     ms = new MediaSession(this, "tag");
     ms.setActive(true);
   }
   
}
#END IF
Make sure to use android.jar from platform 21+.
 
Top