protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); FetchApplyButton = FindViewById <Button>(Resource.Id.FetchApply); FetchSaveButton = FindViewById <Button>(Resource.Id.FetchSave); ClearButton = FindViewById <Button>(Resource.Id.Clear); DeveloperMode = FindViewById <Switch>(Resource.Id.DeveloperMode); ResultLog = (TextView)FindViewById(Resource.Id.log_info); ResultLog.MovementMethod = ScrollingMovementMethod.Instance; //Set User attributes defined in AGConnect Console instance = HiAnalytics.GetInstance(this); instance.SetUserProfile("favorite_color", "Black"); instance.SetUserProfile("favorite_food", "banana"); AGCRemoteConfig = AGConnectConfig.Instance; if (AGCRemoteConfig != null) { Log.Info("RC", "AGConnectConfig instance cratead successfully."); } FetchApplyButton.Click += delegate { FetchApply(); }; FetchSaveButton.Click += delegate { LoadLastFetchedConfig(); }; ClearButton.Click += delegate { AGCRemoteConfig.ClearAll(); Logger("All Values Cleared", TAG); ApplyDefualtByMap(); ShowAllValues(); }; DeveloperMode.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e) { AGCRemoteConfig.SetDeveloperMode(e.IsChecked); if (e.IsChecked) { Toast.MakeText(this, "DeveloperMode Enabled", ToastLength.Long).Show(); } else { Toast.MakeText(this, "DeveloperMode Disabled", ToastLength.Long).Show(); } }; ApplyDefualtByFile(); ShowAllValues(); GetToken(); }
private void Submit_Click(object sender, EventArgs e) { try { string occupation = FindViewById <TextView>(Resource.Id.txtOccupation).Text; string age = FindViewById <TextView>(Resource.Id.txtAge).Text; string color = FindViewById <TextView>(Resource.Id.txtFavoriteColor).Text; instance.SetUserProfile("Occupation", string.IsNullOrEmpty(occupation) ? "Not specified" : occupation); instance.SetUserProfile("Age", string.IsNullOrEmpty(age) ? "Not specified" : age); instance.SetUserProfile("FavoriteColor", string.IsNullOrEmpty(color) ? "Not specified" : color); DisplayAlert("User profile set successfully"); } catch (Exception ex) { Log.Error(TAG, "SettingActivity Exception:" + ex.Message); } }