コード例 #1
0
ファイル: FaceSDKManager.cs プロジェクト: yulongjiang1997/app
        /**
         * FaceSDK 初始化,用户可以根据自己的需求实例化FaceTracker 和 FaceRecognize
         *
         * @param context
         */
        public static void init(Context context)
        {
            Context = context;
            if (!check())
            {
                initStatus = SDK_UNACTIVATION;
                return;
            }
            PreferencesUtil.initPrefs(context.ApplicationContext);
            // final String key = "faceexample-face-android";
            string key = PreferencesUtil.getString("activate_key", "");

            if (Android.Text.TextUtils.IsEmpty(key))
            {
                Toast.MakeText(context, "激活序列号为空, 请先激活", ToastLength.Short).Show();
                return;
            }

            initStatus = SDK_INITING;
            Task.Run(() => { run(key); });
        }
コード例 #2
0
        private LinearLayout initView()
        {
            device = AndroidLicenser.Get_device_id(Contexts.ApplicationContext);
            LinearLayout root = new LinearLayout(Contexts);

            root.Orientation = Android.Widget.Orientation.Vertical;
            LinearLayout.LayoutParams rootParams = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            rootParams.Gravity = GravityFlags.Center;
            root.SetBackgroundColor(Android.Graphics.Color.White);
            root.Focusable            = true;
            root.FocusableInTouchMode = true;

            TextView titleTv = new TextView(Contexts);

            titleTv.Text     = "设备激活";
            titleTv.TextSize = dip2px(15);
            titleTv.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.Black));

            LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WrapContent,
                LinearLayout.LayoutParams.WrapContent);
            titleParams.Gravity     = GravityFlags.Center;
            titleParams.TopMargin   = dip2px(10);
            titleParams.RightMargin = dip2px(30);
            titleParams.LeftMargin  = dip2px(30);

            deviceIdTv = new TextView(Contexts);
            deviceIdTv.SetTextIsSelectable(true);
            deviceIdTv.Text     = "设备指纹:" + device;
            deviceIdTv.TextSize = dip2px(12);
            deviceIdTv.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.Black));

            LinearLayout.LayoutParams deviceIdParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WrapContent,
                LinearLayout.LayoutParams.WrapContent);
            deviceIdParams.Gravity     = GravityFlags.Center;
            deviceIdParams.TopMargin   = dip2px(40);
            deviceIdParams.RightMargin = dip2px(30);
            deviceIdParams.LeftMargin  = dip2px(30);

            KeyEt      = new EditText(Contexts);
            KeyEt.Hint = "输入序列号";
            KeyEt.Text = PreferencesUtil.getString("activate_key", "");
            // keyEt.setText("VMVY-PLkd-OsJN-veIc");

            LinearLayout.LayoutParams keyParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
            keyParams.Gravity          = GravityFlags.Center;
            keyParams.TopMargin        = dip2px(40);
            keyParams.RightMargin      = dip2px(30);
            keyParams.LeftMargin       = dip2px(30);
            KeyEt.TransformationMethod = new AllCapTransformationMethod(true);
            KeyEt.SetWidth(dip2px(260));

            LinearLayout.LayoutParams activateParams = new LinearLayout.LayoutParams(dip2px(180), dip2px(40));
            activateParams.Gravity     = GravityFlags.Center;
            activateParams.TopMargin   = dip2px(40);
            activateParams.RightMargin = dip2px(40);
            activateParams.LeftMargin  = dip2px(40);
            activateBtn = new Button(Contexts);
            // activateBtn.setId(100);
            activateBtn.Text     = "在线激活";
            activateBtn.TextSize = dip2px(12);
            activateBtn.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));
            activateBtn.SetBackgroundColor(Contexts.Resources.GetColor(Resource.Color.material_blue_grey_800));

            LinearLayout.LayoutParams activateParamsone = new LinearLayout.LayoutParams(dip2px(360), dip2px(48));
            activateParamsone.Gravity     = GravityFlags.Center;
            activateParamsone.TopMargin   = dip2px(8);
            activateParamsone.RightMargin = dip2px(20);
            activateParamsone.LeftMargin  = dip2px(60);
            tvOnLineText          = new TextView(Contexts);
            tvOnLineText.Text     = "在线激活:输入序列号,保持设备联网,SDK会自动进行激活";
            tvOnLineText.TextSize = dip2px(8);
            tvOnLineText.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));

            LinearLayout.LayoutParams activateParamsoffLine = new LinearLayout.LayoutParams(dip2px(180), dip2px(40));
            activateParamsoffLine.Gravity     = GravityFlags.Center;
            activateParamsoffLine.TopMargin   = dip2px(5);
            activateParamsoffLine.RightMargin = dip2px(40);
            activateParamsoffLine.LeftMargin  = dip2px(40);
            btOffLineActive = new Button(Contexts);
            // activateBtn.setId(100);
            activateBtn.Text     = "离线激活";
            activateBtn.TextSize = dip2px(12);
            activateBtn.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));
            activateBtn.SetBackgroundColor(Contexts.Resources.GetColor(Resource.Color.material_blue_grey_800));


            LinearLayout.LayoutParams tvOffLineParams = new LinearLayout.LayoutParams(dip2px(380), dip2px(48));
            tvOffLineParams.Gravity     = GravityFlags.Center;
            tvOffLineParams.TopMargin   = dip2px(8);
            tvOffLineParams.RightMargin = dip2px(20);
            tvOffLineParams.LeftMargin  = dip2px(20);
            tvOffLineText          = new TextView(Contexts);
            tvOffLineText.Text     = "离线激活:将激活文件置于SD卡根目录(/storage/emulated/0)中,SDK会自动进行激活";
            tvOffLineText.TextSize = dip2px(8);
            tvOffLineText.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));

            LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(dip2px(180), dip2px(40));
            backParams.Gravity      = GravityFlags.Center;
            backParams.TopMargin    = dip2px(5);
            backParams.BottomMargin = dip2px(20);
            backParams.RightMargin  = dip2px(40);
            backParams.LeftMargin   = dip2px(40);
            backBtn = new Button(Contexts);
            // activateBtn.setId(100);
            backBtn.Text = "返      回";
            backBtn.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));
            backBtn.SetBackgroundColor(Contexts.Resources.GetColor(Resource.Color.material_blue_grey_800));
            backBtn.TextSize = dip2px(12);

            root.AddView(titleTv, titleParams);
            root.AddView(deviceIdTv, deviceIdParams);
            root.AddView(KeyEt, keyParams);
            root.AddView(activateBtn, activateParams);
            root.AddView(tvOnLineText, activateParamsone);
            root.AddView(btOffLineActive, activateParamsoffLine);
            root.AddView(tvOffLineText, tvOffLineParams);
            root.AddView(backBtn, backParams);
            return(root);
        }