How to use the tns-core-modules/application.android function in tns-core-modules

To help you get started, we’ve selected a few tns-core-modules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / NativeScript / tests / app / application / application-tests-common.ts View on Github external
// >> application-require
import * as app from "tns-core-modules/application";
import * as platform from "tns-core-modules/platform";
// << application-require

// >> application-app-check
if (app.android) {
    console.log("We are running on Android device!");
} else if (app.ios) {
    console.log("We are running on iOS device");
}
// << application-app-check

import * as TKUnit from "../TKUnit";

export var testInitialized = function () {
    if (platform.device.os === platform.platformNames.android) {
        // we have the android defined
        TKUnit.assert(app.android, "Application module not properly intialized");
    } else if (platform.device.os === platform.platformNames.ios) {
        TKUnit.assert(app.ios, "Application module not properly intialized");
    }
}
github EddyVerbruggen / nativescript-plugin-firebase / src / firebase.android.ts View on Github external
resolve({
            deepLink: deepLinkUri === null ? null : deepLinkUri.toString(),
            matchType: deepLinkUri === null ? null : 1,
            invitationId: firebaseAppInvite.getInvitationId() // string | null
          });
        }
      });

      const onFailureListener = new com.google.android.gms.tasks.OnFailureListener({
        onFailure: exception => {
          reject(exception.getMessage());
        }
      });

      firebaseDynamicLinks.getDynamicLink(appModule.android.startActivity.getIntent())
          .addOnSuccessListener(onSuccessListener)
          .addOnFailureListener(onFailureListener);

    } catch (ex) {
      console.log("Error in firebase.getInvitation: " + ex);
      reject(ex);
    }
  });
};
github EddyVerbruggen / nativescript-bluetooth / bluetooth.android.js View on Github external
Bluetooth._coarseLocationPermissionGranted = function () {
  var hasPermission = android.os.Build.VERSION.SDK_INT < 23; // Android M. (6.0)
  if (!hasPermission) {
    hasPermission = android.content.pm.PackageManager.PERMISSION_GRANTED ==
        android.support.v4.content.ContextCompat.checkSelfPermission(application.android.foregroundActivity, android.Manifest.permission.ACCESS_COARSE_LOCATION);
  }
  return hasPermission;
};
github EddyVerbruggen / nativescript-bluetooth / src / android / android_main.ts View on Github external
// RESULT_OK = -1
              if (args.resultCode === android.app.Activity.RESULT_OK) {
                this.sendEvent(Bluetooth.bluetooth_enabled_event);
                resolve(true);
              } else {
                resolve(false);
              }
            } catch (ex) {
              CLog(CLogTypes.error, ex);
              application.android.off(application.AndroidApplication.activityResultEvent, onBluetoothEnableResult);
              this.sendEvent(Bluetooth.error_event, { error: ex }, `Bluetooth.enable ---- error: ${ex}`);
              reject(ex);
              return;
            }
          } else {
            application.android.off(application.AndroidApplication.activityResultEvent, onBluetoothEnableResult);
            resolve(false);
            return;
          }
        };
github EddyVerbruggen / nativescript-pluginshowcase / app / utils / status-bar-util.ts View on Github external
export function setStatusBarColors() {
  // Make the iOS status bar transparent with white text
  if (application.ios) {
    application.on("launch", () => UIApplication.sharedApplication.setStatusBarStyleAnimated(UIStatusBarStyle.LightContent, true));
  }

  // Make the Android status bar transparent
  if (application.android) {
    // TODO make sure this works when --uglify'd, otherwise use "activityStarted"
    application.android.on(application.AndroidApplication.activityStartedEvent, (data: application.AndroidActivityEventData) => {
      if (application.android && device.sdkVersion >= "21") {
        let View = android.view.View;
        let window = application.android.startActivity.getWindow();
        window.setStatusBarColor(0x000000);

        let decorView = window.getDecorView();
        decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            // | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
      }
    });
  }
github rhanb / nativescript-swipe-layout / src / yourplugin.common.ts View on Github external
public static SUCCESS_MSG(): string {
    let msg = `Your plugin is working on ${app.android ? 'Android' : 'iOS'}.`;

    setTimeout(() => {
      dialogs.alert(`${msg} For real. It's really working :)`).then(() => console.log(`Dialog closed.`));
    }, 2000);

    return msg;
  }
}
github NativeScript / nativescript-sdk-examples-ng / app / ng-ui-widgets-category / ng-directives / ngif-directive-advanced / ngif-directive-advanced.component.ts View on Github external
ngOnInit() {
        if (application.ios) {
            this.isAndroid = false;
            this.isIos = true;
        } else if (application.android) {
            this.isAndroid = true;
            this.isIos = false;
        }
    }
}
github braune-digital / nativescript-share-file / src / share-file.android.ts View on Github external
_cleanAttachmentFolder() {
        if (application.android.context) {
          let dir = application.android.context.getExternalCacheDir();
          let storage = dir.toString() + "/filecomposer";
          let cacheFolder = fs.Folder.fromPath(storage);
          cacheFolder.clear();
        }
      }
      toStringArray(arg) {
github xlmnxp / nativescript-menu / src / menu.android.ts View on Github external
return new Promise((resolve, reject) => {
      try {
        let popupMenu = new android.widget.PopupMenu(
          app.android.foregroundActivity,
          options.view.android
        );

        if (options.actions[0] !== undefined) {
          if (Types.isString(options.actions[0])) {
            for (let i = 0; i < options.actions.length; i++) {
              const action = options.actions[i];
              popupMenu.getMenu().add(action);
            }

            popupMenu.setOnMenuItemClickListener(
              new android.widget.PopupMenu.OnMenuItemClickListener({
                onMenuItemClick: (item): boolean => {
                  resolve({
                    id: options.actions.indexOf(item.getTitle()),
                    title: item.getTitle()
github charsleysa / nativescript-mdc / src / components / core / android / utils.ts View on Github external
export function getLayout(id: string) {
    if (!id) {
        return 0;
    }
    const context: android.content.Context = application.android.context;
    return context.getResources().getIdentifier(id, 'layout', context.getPackageName());
}