Volume Button

31 views
Skip to first unread message

Lee Tarry

unread,
Jun 19, 2017, 5:45:26 AM6/19/17
to DroidScript
Is there a way to register when the volume button is pressed?

i would like to disable it so it doesn't control volume but controls another part of the app.

Thanks,

Lee

Steve Garman

unread,
Jun 19, 2017, 6:20:17 AM6/19/17
to DroidScript

var myNum = 0;
function OnStart()
{
app.DisableKeys("VOLUME_UP,VOLUME_DOWN");
app.SetOnKey( keypressed );
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
txt = app.CreateText( myNum);
txt.SetTextSize( 32 );
lay.AddChild( txt );

app.AddLayout( lay );
}
function keypressed(type,name)
{
if(name=="VOLUME_UP" && type=="Down")
myNum +=1;
else if(name=="VOLUME_DOWN" && type=="Down")
myNum -=1;
else return;
txt.SetText( myNum );
}

Lee Tarry

unread,
Jun 19, 2017, 7:58:33 AM6/19/17
to DroidScript
Wow, Cheers Steve, ill give it a shot when i get home!!

Reply all
Reply to author
Forward
0 new messages