Back

SetRingerMode

JS Py
Hello World

Change the current ringer mode of the device which can be “Normal”, “Vibrate” or “Silent”.

app.SetRingerMode( mode )

See Also: GetRingerMode

Example - SetRingerMode Demo

function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

    spn = app.CreateSpinner( "Normal,Vibrate,Silent" );
    spn.SetOnChange( SetRingerMode );
    lay.AddChild( spn );

    btn = app.CreateButton( "Press Me", 0.3, 0.1 );
    btn.SetOnTouch( Notify );
    lay.AddChild( btn );

    app.AddLayout( lay );
}

function SetRingerMode( mode )
{
    app.SetRingerMode( mode );
}

function Notify()
{
    var ntf = app.CreateNotification();
    ntf.SetMessage( "RingerMode Demo", "RingerMode Demo notifies:", "Helo World" );
    ntf.Notify();
}
from native import app

def OnStart():
    lay = app.CreateLayout( "linear", "VCenter,FillXY" )

    spn = app.CreateSpinner( "Normal,Vibrate,Silent" )
    spn.SetOnChange( SetRingerMode )
    lay.AddChild( spn )

    btn = app.CreateButton( "Press Me", 0.3, 0.1 )
    btn.SetOnTouch( Notify )
    lay.AddChild( btn )

    app.AddLayout( lay )

def SetRingerMode( mode, index):
    app.SetRingerMode( mode )

def Notify():
    ntf = app.CreateNotification()
    ntf.SetMessage( "RingerMode Demo", "RingerMode Demo notifies:", "Hello World" )
    ntf.Notify()
    Copy     Copy All       Run      
String: “Normal” or “Vibrate” or “Silent”