Android Question Media Button Question in Lollipop 5.0.1

Discussion in 'Android Questions' started by Chris Williams, Mar 26, 2015.

  1. Chris Williams

    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)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    How are you intercepting the media button? With an intent filter?
     
  3. Chris Williams

    Chris Williams Member Licensed User

    Yes, it was an intent filter. Also, my screen lock has a fingerprint recognizer (if that means anything)
     
  4. Chris Williams

    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...
     
  5. Chris Williams

    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...
     
  6. Chris Williams

    Chris Williams Member Licensed User

    ...Any suggestions or information...?
     
  7. Erel

    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:
    Code:
    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+.
     
  8. Chris Williams

    Chris Williams Member Licensed User

    Thank you Erel. I will get to work on this when I return home in a couple of days!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice