當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript application.android類代碼示例

本文整理匯總了TypeScript中application.android的典型用法代碼示例。如果您正苦於以下問題:TypeScript android類的具體用法?TypeScript android怎麽用?TypeScript android使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了android類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: setStatusBarColors

export function setStatusBarColors() {
  // Make the iOS status bar transparent with white text.
  if (application.ios) {
    application.on("launch", () => {
      utils.ios.getter(UIApplication, UIApplication.sharedApplication).statusBarStyle = UIStatusBarStyle.LightContent;
    });
  }

  // Make the Android status bar transparent.
  // See http://bradmartin.net/2016/03/10/fullscreen-and-navigation-bar-color-in-a-nativescript-android-app/
  // for details on the technique used.
  if (application.android && platform.device.sdkVersion >= "21") {
    application.android.on("activityStarted", () => {
      const View = android.view.View;
      const window = application.android.startActivity.getWindow();
      window.setStatusBarColor(0x000000);

      const 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);
    });
  }
}
開發者ID:msegeya,項目名稱:sample-Groceries,代碼行數:26,代碼來源:status-bar-util.ts

示例2: Promise

 new Promise(function(resolve, reject) {
     var callback = function(requestPermissionsEventData: AndroidRequestPermissionsResultEventData) {
         if (requestPermissionsEventData.requestCode == CAMERA_PERMISSION_REQUEST_CODE) {
             resolve(android.content.pm.PackageManager.PERMISSION_GRANTED == requestPermissionsEventData.grantResults[0]);
             appInstance.off(AndroidApplication.requestPermissionsEvent, callback);
         }
     }
     appInstance.on(AndroidApplication.requestPermissionsEvent, callback);
     android.support.v4.app.ActivityCompat.requestPermissions(context, [android.Manifest.permission.CAMERA], CAMERA_PERMISSION_REQUEST_CODE);
 });
開發者ID:rajivnarayana,項目名稱:nativescript-zxing-embed,代碼行數:10,代碼來源:barcode-scanner.android.ts

示例3:

    application.on("launch", args => {
        console.log("onLaunch");
        com.facebook.drawee.backends.pipeline.Fresco.initialize(application.android.context);
        application.android.on("activityStarted", ({activity}) => {
            console.log("onStarted");
            var window = activity.getWindow();
            if (window) {
                window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(0xFF151F2F));

                // Prevent the soft keyboard from hiding EditText's while typing.
                window.setSoftInputMode(32); //android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;
            }
        });
    });
開發者ID:phattranky,項目名稱:nativescript-marketplace-demo,代碼行數:14,代碼來源:main-common.ts

示例4: constructor

    constructor() {
        if (application.android) {
            console.log("We are running on Android device!");
            this.isItemVisible = true;

            // >> app-android-dirs-code
            this.fileList = [];
            this.appContext = application.android.context;
            this.filesDir = this.appContext.getFilesDir();
            this.cacheDir = this.appContext.getCacheDir();

            let files = this.appContext.fileList();
            for (let index = 0; index < files.length; index++) {
                let element = files[index];
                this.fileList.push(element.toString());
            }
            // << app-android-dirs-code

            // >> app-android-broadcast-code
            this.batteryLife = "0";
            let that = this;

            application.android.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED,
                function onReceiveCallback(context: android.content.Context, intent: android.content.Intent) {
                    let level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1);
                    let scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1);
                    let percent = (level / scale) * 100.0;

                    that.batteryLife = percent.toString();
                });
            // << app-android-broadcast-code
        } else if (application.ios) {
            console.log("We are running on iOS device");
            this.isItemVisible = false;
        }
    }
開發者ID:aymenbraiek,項目名稱:nativescript-sdk-examples-ng,代碼行數:36,代碼來源:app-using-android-specifics.component.ts

示例5: function

 var callback = function(requestPermissionsEventData: AndroidRequestPermissionsResultEventData) {
     if (requestPermissionsEventData.requestCode == CAMERA_PERMISSION_REQUEST_CODE) {
         resolve(android.content.pm.PackageManager.PERMISSION_GRANTED == requestPermissionsEventData.grantResults[0]);
         appInstance.off(AndroidApplication.requestPermissionsEvent, callback);
     }
 }
開發者ID:rajivnarayana,項目名稱:nativescript-zxing-embed,代碼行數:6,代碼來源:barcode-scanner.android.ts


注:本文中的application.android類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。