Android Question BroadCastReceiver to know VOLUME_UP or VOLUME_DOWN is pressed

Discussion in 'Android Questions' started by Albert Lin, Oct 15, 2016.

  1. Albert Lin

    Albert Lin Member Licensed User

    Dear All

    I use BroadCastReceiver to detect KEYCODE_VOLUME_UP or KEYCODE_VOLUME_UP pressed
    the code is as following. but how to know which key is pressed? Is KEYCODE_VOLUME_UP or KEYCODE_VOLUME_UP?

    Best Regards
    Albert Lin

    Sub Service_Create
    End Sub

    Sub Service_Start (StartingIntent As Intent)
    End Sub

    Sub Service_Destroy
    End Sub
    Sub BR_OnReceive(Action As String, Extras As Object)
        gVibrate.Vibrate (
    End Sub
  2. Erel

    Erel Administrator Staff Member Licensed User

    Note that it is better to register it in Service_Create. Service_Start can be called multiple times.

    What is the output of Log(Extras)?
  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