There are times when you need to open a file in a particular app like Adobe Reader and you want to know whether this app is installed on the device or not.
You can do so using the following code in NativeScript:

function app_installed(packageName){
    var context = utils.ad.getApplicationContext();
    var pm = context.getPackageManager();
    var app_installed = false;
    try {
        pm.getPackageInfo(packageName, android.content.pm.PackageManager.GET_ACTIVITIES);
        app_installed = true;
    }
    catch(e) {
        app_installed = false;
    }
    return app_installed;
}

Just use app_installed('com.facebook.katana') or app_installed('com.adobe.reader') and it will return true or false for your logic.