Show or hide the Android Status Bar in NativeScript

I was trying to get the status bar to hide in one of the apps and created a simple code to do that.

var application = require('application').android;
function statusBar(action){
    var activity = application.startActivity;
    var win = activity.getWindow();
    if(action === 'hide'){
    } else if(action === 'show'){

Then call statusBar('show') or statusBar('hide') in your pageloaded event.