public override void OnCreate() { base.OnCreate(); Instance = this; // Load preferences Preferences = GetSharedPreferences(SettingsFilename, FileCreationMode.Private); // Default offline mode D3Context.Instance.FetchMode = (Preferences.GetBoolean(SettingsOnlinemode, false) ? FetchMode.Online : FetchMode.OnlineIfMissing); // Checks if some migration operations are needed var upToDateVersion = Preferences.GetInt(UpToDateVersion, 1); if (upToDateVersion < 20) { new MigrationTo20().DoMigration(); } // Always start D3Api with cache available var dataProvider = new CacheableDataProvider(new HttpRequestDataProvider()) { FetchMode = D3Context.Instance.FetchMode }; D3Api.DataProvider = dataProvider; // Set english locale by default D3Api.Locale = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; }
public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); var context = Activity; var dm = context.Resources.DisplayMetrics; // mResourceProxy = new ResourceProxyImpl(getActivity().getApplicationContext()); _prefs = context.GetSharedPreferences(OpenStreetMapConstants.PrefsName, FileCreationMode.Private); _compassOverlay = new CompassOverlay(context, new InternalCompassOrientationProvider(context), _mapView); _myLocationOverlay = new MyLocationNewOverlay(context, new GpsMyLocationProvider(context), _mapView); _minimapOverlay = new MinimapOverlay(Activity, _mapView.TileRequestCompleteHandler) { Width = dm.WidthPixels/5, Height = dm.HeightPixels/5 }; _scaleBarOverlay = new ScaleBarOverlay(context); _scaleBarOverlay.SetCentred(true); _scaleBarOverlay.SetScaleBarOffset(dm.WidthPixels/2, 10); _rotationGestureOverlay = new RotationGestureOverlay(context, _mapView) {Enabled = false}; _mapView.SetBuiltInZoomControls(true); _mapView.SetMultiTouchControls(true); _mapView.Overlays.Add(_myLocationOverlay); _mapView.Overlays.Add(_compassOverlay); _mapView.Overlays.Add(_minimapOverlay); _mapView.Overlays.Add(_scaleBarOverlay); _mapView.Overlays.Add(_rotationGestureOverlay); _mapView.Controller.SetZoom(_prefs.GetInt(OpenStreetMapConstants.PrefsZoomLevel, 1)); _mapView.ScrollTo(_prefs.GetInt(OpenStreetMapConstants.PrefsScrollX, 0), _prefs.GetInt(OpenStreetMapConstants.PrefsScrollY, 0)); _myLocationOverlay.EnableMyLocation(); _compassOverlay.EnableCompass(); HasOptionsMenu = true; }
public static AppPreferences Create(ISharedPreferences prefs) { return new AndroidAppPreferences(prefs) { FirtsTimeRunning = prefs.GetBoolean(AppPreferences.FirstTimeKey, true), Ip = prefs.GetString(AppPreferences.IpKey, ""), Port = prefs.GetInt(AppPreferences.PortKey, 0), UseSounds = prefs.GetBoolean(AppPreferences.UseSoundsKey, true), UseCache = prefs.GetBoolean(AppPreferences.UseCacheKey, true) }; }
//**********************Functions****************************************************************// public void LoadList() // Loads items in the shared prefs amd populate list { int count = prefs.GetInt("itemCount", 0); if (count > 0) { Toast.MakeText(this, "Getting saved items...", ToastLength.Short).Show(); for (int i = 0; i <= count; i++) // loop through the number of items { string item = prefs.GetString(i.ToString(), null); if (item != null) { Items.Add(item); // add item in the list } } } }
private async void SetResources() { //Get reference to the needed resources list = FindViewById <ListView>(Resource.Id.HistorialMandadosListView); //obtener id del usuario logueado Context mContext = Application.Context; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(mContext); int sesion_id = prefs.GetInt("id", 0); List <Manboss_mandado> mandados = await core.GetMandados(sesion_id); if (mandados == null) { return; } MandadosAdapter adapter = new MandadosAdapter(this, mandados); list.Adapter = adapter; }
// Implement OnLogin method // username and password VERIFICATION here! (send data to login.php in server to verify) // if verify sucessfully, go to the Friends page // else pop up an error message in this Login page public void OnLogin(object sender, EventArgs e) { ISharedPreferences sharedPref = PreferenceManager.GetDefaultSharedPreferences(this); string Username = sharedPref.GetString("Username", string.Empty); int Password = sharedPref.GetInt("Password", int.MinValue); if (username.Text == Username && password.Text.GetHashCode() == Password) { //**if login successfully, go to FriendsList page with the username var friendsActivity = new Intent(this, typeof(FriendsActivity)); friendsActivity.PutExtra("UserRegisterID", sharedPref.GetString("RegistrationId", string.Empty)); StartActivity(typeof(FriendsActivity)); } else { PreviousLoginActivity(); } }
public void CheckIfPotvrdaExist() { if (localPotvrda.GetBoolean("edit", false)) { // Prikaz dodanih nametnika na provedbenom planu var nametniciList = db.Query <DID_Potvrda_Nametnik>( "SELECT * " + "FROM DID_Potvrda_Nametnik " + "WHERE Potvrda = ?", localPotvrda.GetInt("id", 0)); foreach (var nametnik in nametniciList) { localPotvrdaEdit.PutString("nametnik" + nametnik.Nametnik, nametnik.Nametnik); } localPotvrdaEdit.Commit(); } }
/// <summary> Resets the player to the initial level </summary> public void Reset() { Int32 lives; #if __ANDROID__ ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(GameActivity.Instance); lives = preferences.GetInt(Constants.LIVES_SAVE_ID, 1); #elif __IOS__ lives = (Int32)NSUserDefaults.StandardUserDefaults.IntForKey(Constants.LIVES_SAVE_ID); if (lives == 0) { lives = 1; } #endif _Lives = lives; _RechargeTime = TimeSpan.Zero; Initialise(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainMenu); context = ApplicationContext; InitializeServices(); #region View Linking _MMClassicModeButton = FindViewById <Button>(Resource.Id.MMClassicModeButton); _MMHardcoreModeButton = FindViewById <Button>(Resource.Id.MMHardcoreModeButton); _MMEveryDayModeButton = FindViewById <Button>(Resource.Id.MMEveryDayModeButton); _MMSettingsButton = FindViewById <ImageButton>(Resource.Id.MMSettingsButton); _MMPedestalButton = FindViewById <ImageButton>(Resource.Id.MMPedestalButton); _MMCupButton = FindViewById <ImageButton>(Resource.Id.MMCupButton); _MMTotalPointsTextView = FindViewById <TextView>(Resource.Id.MMTotalPoint); _MMNicknameTextView = FindViewById <TextView>(Resource.Id.MMProfineName); #endregion #region SharedPreference ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context); ISharedPreferencesEditor editor = prefs.Edit(); STotalPoints = prefs.GetInt("SavedTotalPoints", 0); NickName = prefs.GetString("nickname", context.Resources.GetString(Resource.String.notLogged)); #endregion #region Set TextView value from SharedPreference _MMNicknameTextView.SetText(NickName, TextView.BufferType.Normal); _MMTotalPointsTextView.SetText(STotalPoints.ToString(), TextView.BufferType.Normal); #endregion #region Events listener _MMClassicModeButton.Click += _MMClassicModeButton_Click; _MMHardcoreModeButton.Click += _MMHardcoreModeButton_Click; _MMEveryDayModeButton.Click += _MMEveryDayModeButton_Click; _MMSettingsButton.Click += _MMSettingsButton_Click; _MMPedestalButton.Click += _MMPedestalButton_Click; _MMCupButton.Click += _MMCupButton_Click; #endregion }
System.Timers.Timer Timer; // Holds The Global Timer. // ------------------------------- protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.play_layout); // Setting The Background Of The Game Layout. FindViewById <RelativeLayout>(Resource.Id.GameLayout).SetBackgroundResource(Resource.Drawable.space); // Setting The Width And the Height Of The Screen. var Display = Resources.DisplayMetrics; // Getting The Display Metrics. Screen_Width = Display.WidthPixels; // Setting The Screen Width. Screen_Height = Display.HeightPixels; // Setting The Screen Height. // Loading The Game Memory. Memory = this.GetSharedPreferences("Game_Data", FileCreationMode.Private); Current_Level = Memory.GetInt("Current_Level", 1); // Loading The Current User. // Loading The Play Object And Displaying To The Screen. Create_Player(); // Running The Clock. Timer = new System.Timers.Timer(); Timer.Interval = 5; // Runs 50ms Timer.Elapsed += RunTimer; Timer.Enabled = true; // Loading The Level TextViews Create_Level_TextViews(); // Animating The Level TextViews. Load_Level_Animation(); Create_Score_And_Health_Bar(); StartMusic(); }
/// <summary> /// Returns a stored geofence by its ID, or returns null if it's not found /// </summary> /// <returns>A SimpleGeofence defined by its center and radius, or null if the ID is invalid</returns> /// <param name="id">The ID of a stored Geofence</param> public override GeofenceCircularRegion Get(String id) { // Get the latitude for the geofence identified by id, or INVALID_FLOAT_VALUE if it doesn't exist (similarly for the other values that follow) double lat = mPrefs.GetFloat(GetFieldKey(id, LatitudeGeofenceRegionKey), InvalidFloatValue); double lng = mPrefs.GetFloat(GetFieldKey(id, LongitudeGeofenceRegionKey), InvalidFloatValue); double radius = mPrefs.GetFloat(GetFieldKey(id, RadiusGeofenceRegionKey), InvalidFloatValue); bool notifyOnEntry = mPrefs.GetBoolean(GetFieldKey(id, NotifyOnEntryGeofenceRegionKey), false); bool notifyOnExit = mPrefs.GetBoolean(GetFieldKey(id, NotifyOnExitGeofenceRegionKey), false); bool notifyOnStay = mPrefs.GetBoolean(GetFieldKey(id, NotifyOnStayGeofenceRegionKey), false); string notificationEntryMessage = mPrefs.GetString(GetFieldKey(id, NotificationEntryMessageGeofenceRegionKey), string.Empty); string notificationExitMessage = mPrefs.GetString(GetFieldKey(id, NotificationExitMessageGeofenceRegionKey), string.Empty); string notificationStayMessage = mPrefs.GetString(GetFieldKey(id, NotificationStayMessageGeofenceRegionKey), string.Empty); bool showNotification = mPrefs.GetBoolean(GetFieldKey(id, ShowNotificationGeofenceRegionKey), false); bool persistent = mPrefs.GetBoolean(GetFieldKey(id, PersistentGeofenceRegionKey), false); int stayedInThresholdDuration = mPrefs.GetInt(GetFieldKey(id, StayedInThresholdDurationGeofenceRegionKey), InvalidIntValue); //long expirationDuration = mPrefs.GetLong(GetFieldKey(id, ExpirationDurationGeofenceRegionKey), InvalidLongValue); //int transitionType = mPrefs.GetInt(GetFieldKey(id, TransitionTypeGeofenceRegionKey), InvalidIntValue); // If none of the values is incorrect, return the object if (lat != InvalidFloatValue && lng != InvalidFloatValue && radius != InvalidFloatValue && persistent && stayedInThresholdDuration != InvalidIntValue // && expirationDuration != InvalidLongValue //&& transitionType != InvalidIntValue ) { return new GeofenceCircularRegion(id, lat, lng, radius, notifyOnEntry, notifyOnExit, notifyOnStay, showNotification, persistent) { NotificationEntryMessage = notificationEntryMessage, NotificationStayMessage = notificationStayMessage, NotificationExitMessage = notificationExitMessage, StayedInThresholdDuration = TimeSpan.FromMilliseconds(stayedInThresholdDuration) } } ; // Otherwise return null return(null); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.lokacije); Android.Widget.Toolbar toolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbarHomePage); lokacijaListView = FindViewById <RecyclerView>(Resource.Id.recyclerView); searchInput = FindViewById <EditText>(Resource.Id.searchInput); resultMessage = FindViewById <TextView>(Resource.Id.resultMessage); novaLokacijaBtn = FindViewById <Button>(Resource.Id.novaLokacijaBtn); SetActionBar(toolbar); ActionBar.Title = "Odabir lokacije"; localAnketa.Edit().Clear().Commit(); localPozicija.Edit().Clear().Commit(); localPotvrda.Edit().Clear().Commit(); localNeizvrsernaLokacija.Edit().Clear().Commit(); localProvedbeniPlan.Edit().Clear().Commit(); localKomitentLokacijaEdit.PutBoolean("noviKomitent", false); string sifraPartnera = localKomitentLokacija.GetString("sifraKomitenta", null); radniNalog = localRadniNalozi.GetInt("id", 0); lokacijeList = db.Query <DID_Lokacija>( "SELECT * " + "FROM DID_Lokacija " + "INNER JOIN T_KUPDOB ON DID_Lokacija.SAN_KD_SIFRA = T_KUPDOB.SIFRA " + "INNER JOIN DID_RadniNalog_Lokacija ON DID_Lokacija.SAN_Id = DID_RadniNalog_Lokacija.Lokacija " + "WHERE DID_Lokacija.SAN_KD_Sifra = ? " + "AND DID_RadniNalog_Lokacija.RadniNalog = ?", sifraPartnera, radniNalog); lokacijeListFiltered = lokacijeList; mLayoutManager = new LinearLayoutManager(this); mAdapter = new Adapter_LokacijeRecycleView(lokacijeListFiltered); lokacijaListView.SetLayoutManager(mLayoutManager); lokacijaListView.SetAdapter(mAdapter); mAdapter.ItemPotvrda += MAdapter_PotvrdaClick; mAdapter.ItemClick += MAdapter_ItemClick; mAdapter.ItemZakljucaj += MAdapter_ItemZakljucaj; mAdapter.ItemProvedbeniPlan += MAdapter_ItemProvedbeniPlan; mAdapter.ItemPostavke += MAdapter_ItemPostavke; searchInput.KeyPress += SearchInput_KeyPress; searchInput.TextChanged += SearchInput_TextChanged; novaLokacijaBtn.Click += NovaLokacijaBtn_Click; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.fragment_kosu_mantan, container, false); prefs = PreferenceManager.GetDefaultSharedPreferences(Context); editor = prefs.Edit(); HideFooter(); kosuMenuflag = prefs.GetInt(Const.KOSU_MENU_FLAG, (int)Const.KOSU_MENU.TODOKE); // 画面区分 listView = view.FindViewById <ListView>(Resource.Id.lv_matehanList); listView.ItemClick += (object sender, ItemClickEventArgs e) => { SelectListViewItem(e.Position); }; txtVenderName = view.FindViewById <TextView>(Resource.Id.vendorName); txtVenderName.Text = prefs.GetString("vendor_nm", ""); etMantanVendor = view.FindViewById <BootstrapEditText>(Resource.Id.et_mantan_vendor); etMantanVendor.Text = prefs.GetString("vendor_cd", ""); BootstrapButton vendorSearchButton = view.FindViewById <BootstrapButton>(Resource.Id.vendorSearch); vendorSearchButton.Click += delegate { StartFragment(FragmentManager, typeof(KosuVendorAllSearchFragment)); }; etMantanVendor.KeyPress += (sender, e) => { if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) { e.Handled = true; CommonUtils.HideKeyboard(Activity); SetMatehanList(); } else { e.Handled = false; } }; SetMatehanList(); return(view); }
public static double GetStorageDoubleValue(string appName, string key) { ISharedPreferences pref = Application.Context.GetSharedPreferences(appName, FileCreationMode.Private); try { return(Convert.ToDouble(pref.GetFloat(key, 0f))); } catch { try { return(Convert.ToDouble(pref.GetInt(key, 0))); } catch { return(0.0); } } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.fragment_kosu_select, container, false); prefs = PreferenceManager.GetDefaultSharedPreferences(Context); editor = prefs.Edit(); //ShowFooter(); kosuMenuflag = prefs.GetInt(Const.KOSU_MENU_FLAG, (int)Const.KOSU_MENU.TODOKE); // 画面区分 soukoCd = prefs.GetString("souko_cd", ""); kitakuCd = prefs.GetString("kitaku_cd", ""); editor.PutString("ko_su", "0"); editor.PutString("dai_su", "0"); editor.Apply(); InitComponent(); return(view); }
private void BtnGoNext_Click(object sender, EventArgs e) { WebClient client = new WebClient(); Uri uri = new Uri("http://packstudy-com.stackstaging.com/addcourses.php"); NameValueCollection parameter = new NameValueCollection(); ISharedPreferences sharedPrefrences = GetSharedPreferences("MyData", FileCreationMode.Private); int UserId = sharedPrefrences.GetInt("id", 0); foreach (Course c in CourseList) { parameter.Add("UserId", UserId.ToString()); parameter.Add("CourseId", c.id); parameter.Add("SemesterId", c.semester); byte[] returnValue = client.UploadValues(uri, parameter); string r = Encoding.ASCII.GetString(returnValue); parameter.Remove("UserId"); parameter.Remove("CourseId"); parameter.Remove("SemesterId"); } }
public static T Get <T>(string key) { var type = typeof(T); object value = default(T); if (type == typeof(int)) { value = _preferences.GetInt(key, -1); } else if (type == typeof(string)) { value = _preferences.GetString(key, ""); } else if (type == typeof(bool)) { value = _preferences.GetBoolean(key, false); } return((T)value); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ActionBar.SetDisplayShowHomeEnabled(false); ActionBar.SetDisplayShowTitleEnabled(false); ActionBar.SetCustomView(Resource.Layout.actionbar_main); ActionBar.SetDisplayShowCustomEnabled(true); SetContentView(Resource.Layout.activity_main); prefs = PreferenceManager.GetDefaultSharedPreferences(this); editor = prefs.Edit(); editor.PutString("dbPath", dbPath); if (prefs.GetInt("difficultyId", 0) == 0) { editor.PutInt("difficultyId", 1); } editor.Apply(); dbManager = new DatabaseManager(dbPath); dbManager.CreateTable(); var highscoreBtn = FindViewById <Button>(Resource.Id.main_btn_highscore); var startBtn = FindViewById <Button>(Resource.Id.btn_main_start); var subjectsBtn = FindViewById <Button>(Resource.Id.btn_main_tema); var btnVanskelighetsgrad = FindViewById <Button>(Resource.Id.btn_main_vanskelighetsgrad); highscoreBtn.Click += HighscoreBtn_Click; startBtn.Click += StartBtn_Click; subjectsBtn.Click += SubjectsBtn_Click; btnVanskelighetsgrad.Click += BtnVanskelighetsgrad_Click; tvPlayer = FindViewById <TextView>(Resource.Id.tv_actionbar_player_name); tvPlayer.Text = prefs.GetString("player", null); ivPlayer = FindViewById <ImageView>(Resource.Id.iv_actionbar_player); ivPlayer.Click += IvPlayer_Click; RefreshScreen(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.potroseniMaterijali_PrikazPozicija); Android.Widget.Toolbar toolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbarHomePage); materijaliListView = FindViewById <ListView>(Resource.Id.materijaliListView); partnerData = FindViewById <TextView>(Resource.Id.partnerData); lokacijaData = FindViewById <TextView>(Resource.Id.lokacijaData); materijalData = FindViewById <TextView>(Resource.Id.materijalData); SetActionBar(toolbar); ActionBar.Title = "Pozicije"; radniNalog = localRadniNalozi.GetInt("id", 0); materijalSifra = localMaterijali.GetString("sifra", null); lokacijaId = localKomitentLokacija.GetInt("lokacijaId", 0); lokacijaData.Text = db.Query <DID_Lokacija>( "SELECT * " + "FROM DID_Lokacija " + "WHERE SAN_Id = ?", lokacijaId).FirstOrDefault().SAN_Naziv; materijalData.Text = db.Query <T_NAZR>( "SELECT * " + "FROM T_NAZR " + "WHERE NAZR_SIFRA = ?", materijalSifra).FirstOrDefault().NAZR_NAZIV; partnerData.Text = db.Query <T_KUPDOB>( "SELECT * " + "FROM T_KUPDOB " + "WHERE SIFRA = ?", localMaterijali.GetString("sifraPartnera", null)).FirstOrDefault().NAZIV; pozicije = db.Query <DID_LokacijaPozicija>( "SELECT * " + "FROM DID_LokacijaPozicija poz " + "INNER JOIN DID_AnketaMaterijali mat ON poz.POZ_Id = mat.PozicijaId " + "WHERE mat.RadniNalog = ? " + "AND poz.SAN_Id = ? " + "AND mat.MaterijalSifra = ? " + "GROUP BY poz.POZ_Broj, poz.POZ_BrojOznaka", radniNalog, lokacijaId, materijalSifra); materijaliListView.Adapter = new Adapter_MaterijaliPozicija(this, pozicije); materijaliListView.ItemClick += PartneriListView_ItemClick; }
public void ReadSharedPreferences() { ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Current); preferences.sound = prefs.GetBoolean("sound", false); preferences.sound_volume = prefs.GetInt("sound_volume", 10); preferences.vibration = prefs.GetBoolean("vibration", false); preferences.sabiranje = prefs.GetInt("sabiranje", 100); preferences.oduzimanje = prefs.GetInt("oduzimanje", 100); preferences.mnozenje = prefs.GetInt("mnozenje", 100); preferences.deljenje = prefs.GetInt("deljenje", 100); var lang = prefs.GetInt("language", 0); preferences.language = (lang == 0) ? LangEnum.Cirilica : LangEnum.Latinica; }
private void RestoreInstanceState() { ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); ourState = (State)prefs.GetInt("OurState", 2); switch (ourState) { case State.DisplayingFavourites: txtViewSettings.Text = Helpers.ReadFavourites(favouritesPath) ?? "No favourites have been created yet"; break; case State.DisplayingSettings: txtViewSettings.Text = Helpers.ReadXonfSettings(xOnfluencePath) ?? "Failed to read Xonfluence settings.xml"; break; case State.DisplayingNothing: txtViewSettings.Text = ""; break; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); View firstView = inflater.Inflate(Resource.Layout.SecondFragment, container, false); myListView = firstView.FindViewById <ListView>(Resource.Id.sslistview); ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(context); usersList = dBHelper.GetUserFavoritesList(preferences.GetInt("userId", 0)); var adapter = new MyCustomAdapter(context, usersList); myListView.SetAdapter(adapter); myListView.ItemClick += userListviewClickEvent; return(firstView); // return base.OnCreateView(inflater, container, savedInstanceState); }
public void AddNote() { //add the notes to note centre //using ISharedPreferences to get data in path // the data path is data/data/supercalendar ISharedPreferences sp = this.GetSharedPreferences("abc", FileCreationMode.Private); //get the id of each notes the value is size int size = sp.GetInt("size", 0); //to display every notes on listview for (int i = 0; i <= size; i++) { string title = sp.GetString("title" + i, ""); string date = sp.GetString("date" + i, ""); string des = sp.GetString("des" + i, ""); Info info = new Info { Title = title, Date = date, Des = des }; notesList.Add(info); } }
protected override void OnStart() { base.OnStart(); Kp2aLog.Log("KeePass.OnStart"); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); bool showChangeLog = false; try { PackageInfo packageInfo = PackageManager.GetPackageInfo(PackageName, 0); int lastInfoVersionCode = prefs.GetInt(GetString(Resource.String.LastInfoVersionCode_key), 0); if (packageInfo.VersionCode > lastInfoVersionCode) { showChangeLog = true; ISharedPreferencesEditor edit = prefs.Edit(); edit.PutInt(GetString(Resource.String.LastInfoVersionCode_key), packageInfo.VersionCode); EditorCompat.Apply(edit); } } catch (PackageManager.NameNotFoundException) { } #if DEBUG showChangeLog = false; #endif if (showChangeLog) { ChangeLog.ShowChangeLog(this, LaunchNextActivity); } else { LaunchNextActivity(); } }
//override of the activity result to post images to the database. This event is fired once //a new image is chosen from the gallery protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if ((requestCode == PickImageId) && (resultCode == Result.Ok) && (data != null)) { WebClient Client = new System.Net.WebClient(); string imagePath = UriHelper.GetPathFromUri(this, data.Data); Client.Headers.Add("Content-Type", "binary/octet-stream"); //upload image to web server via php and bitmap byte[] result = Client.UploadFile("http://packstudy-com.stackstaging.com/uploadFileMessage.php", "POST", imagePath); //display the uploaded image string s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length); if (s == "sucess") { string[] substrings = imagePath.Split('/'); string urlFilePath = "http://packstudy-com.stackstaging.com/fileUploads/" + substrings[substrings.Length - 1]; ISharedPreferences sharedPrefrences = GetSharedPreferences("MyData", FileCreationMode.Private); int UserId = sharedPrefrences.GetInt("id", 0); WebClient client = new WebClient(); Uri uri = new Uri("http://packstudy-com.stackstaging.com/sendmessage.php"); NameValueCollection parameter = new NameValueCollection(); //add each of the parameters that need to be posted witht he photo string FirstName = sharedPrefrences.GetString("FirstName", null); string LastName = sharedPrefrences.GetString("LastName", null); parameter.Add("UserId", UserId.ToString()); currentCourse = sharedPrefrences.GetString("CurrentCourse", null); parameter.Add("Semester", "Spring2017"); parameter.Add("Course", currentCourse); parameter.Add("Message", "FILE_" + urlFilePath); parameter.Add("Name", FirstName + " " + LastName); //send the messsage byte[] returnValue = client.UploadValues(uri, parameter); string r = Encoding.ASCII.GetString(returnValue); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.AddFlags(WindowManagerFlags.KeepScreenOn); SupportActionBar.SetDisplayShowHomeEnabled(true); App.STATE.Activity = this; App.FUNCTIONS.SetActionBarDrawable(this); preferences = PreferenceManager.GetDefaultSharedPreferences(this); mainExpansionFileVersion = preferences.GetInt("MainExpansionFileVersion", 1); if (mainExpansionFileVersion == MAIN_EXPANSION_FILE_VERSION) { StartApplication(); } else { #if DEBUG // Before we do anything, are the files we expect already here and // delivered (presumably by Market) // For free titles, this is probably worth doing. (so no Market // request is necessary) var delivered = AreExpansionFilesDelivered(); if (delivered) { StorehouseInitializationParadigm(); } if (!GetExpansionFiles()) { InitializeDownloadUI(); } #else StorehouseInitializationParadigm(); #endif } }
public override bool OnCreateOptionsMenu(IMenu menu) { MenuInflater.Inflate(Resource.Menu.menu_shopping, menu); var item = menu.FindItem(Resource.Id.search); var item2 = menu.FindItem(Resource.Id.action_cart); var searchView = MenuItemCompat.GetActionView(item); _searchView = searchView.JavaCast <Android.Support.V7.Widget.SearchView>(); var hint = Resources.GetString(Resource.String.hint_search_in); _searchView.QueryHint = Resources.GetString(Resource.String.hint_search); _searchView.QueryTextSubmit += SearchView_QueryTextSubmitAsync; _searchView.OnActionViewExpanded(); View actionView = MenuItemCompat.GetActionView(item2); _CartItemCount = actionView.FindViewById <ImageView>(Resource.Id.cart_badge); mCartItemCount = app.GetInt("MyCart", 0); if (mCartItemCount == 0) { _CartItemCount.Visibility = ViewStates.Gone; } else { _CartItemCount.Visibility = ViewStates.Visible; } actionView.Click += (o, e) => { ActivityOptionsCompat option = ActivityOptionsCompat.MakeSceneTransitionAnimation(this); Intent i = new Intent(this, typeof(MyCart_Activity)); StartActivity(i, option.ToBundle()); }; return(base.OnCreateOptionsMenu(menu)); }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { switch (key) { case PreferenceKeys.Timeout: Runner.Instance.Options.Timeout = sharedPreferences.GetInt(key, Runner.Instance.Options.Timeout); break; case PreferenceKeys.SaveNamespaces: if (!sharedPreferences.GetBoolean(key, false)) resetSavedNamespaces(); break; case PreferenceKeys.MultiLineEditing: CSharpToGoApplication.Options.MultiLineEditing = sharedPreferences.GetBoolean(key, CSharpToGoApplication.Options.MultiLineEditing); break; case PreferenceKeys.DoubleEnter: CSharpToGoApplication.Options.DoubleEnterToExecute = sharedPreferences.GetBoolean(key, CSharpToGoApplication.Options.DoubleEnterToExecute); break; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Log.Info(TAG, "\n\nnOnCreate\n\n"); SetContentView(Resource.Layout.start_activity); mInteractor = new StartInteractor(ApplicationContext); mViewModel = new StartViewModel(this, mInteractor); user = new User() { IdUsuario = mUserPreferences.GetInt("IdUsuario", 0), Nombre = mUserPreferences.GetString("Nombre", String.Empty), Cuenta = mUserPreferences.GetString("Cuenta", String.Empty), Contrasena = mUserPreferences.GetString("Contrasena", String.Empty), Perfil = mUserPreferences.GetString("Perfil", String.Empty) }; DescargarValoresNecesarios(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); user = new User() { IdUsuario = mUserPreferences.GetInt("IdUsuario", 0), Nombre = mUserPreferences.GetString("Nombre", String.Empty), Cuenta = mUserPreferences.GetString("Cuenta", String.Empty), Contrasena = mUserPreferences.GetString("Contrasena", String.Empty), Perfil = mUserPreferences.GetString("Perfil", String.Empty) }; if (user.Cuenta == String.Empty || user.Contrasena == String.Empty) { Log.Info(TAG, "No hay cuenta Activa"); ISharedPreferencesEditor editUser = mUserPreferences.Edit(); editUser.PutInt("IdUsuario", 0); editUser.PutString("Nombre", String.Empty); editUser.PutString("Cuenta", String.Empty); editUser.PutString("Contrasena", String.Empty); editUser.PutString("Perfil", String.Empty); editUser.Apply(); showLoginScreen(); } else { Log.Info(TAG, "Hay cuenta Activa"); Log.Info(TAG, "El usuario es: " + mUserPreferences.GetString("Nombre", String.Empty)); Log.Info(TAG, "El perfil es: " + mUserPreferences.GetString("Perfil", String.Empty)); } /*ActionBar ab = getSupportActionBar(); * if (ab != null) * { * ab.setDisplayHomeAsUpEnabled(true); * } * overridePendingTransition(0, 0);*/ }
/** * @param key The name of the preference to modify. * @param value The new value for the preference. * @see Editor#putStringSet(String, Set) */ public static void putStringSet(string key, HashSet <string> value) { var editor = getPreferences().Edit(); if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Honeycomb) { editor.PutStringSet(key, value); } else { // Workaround for pre-HC's lack of StringSets int stringSetLength = 0; if (mPrefs.Contains(key + LENGTH_SUFFIX)) { // First read what the value was stringSetLength = mPrefs.GetInt(key + LENGTH_SUFFIX, -1); } editor.PutInt(key + LENGTH_SUFFIX, value.Count); int i = 0; foreach (string aValue in value) { editor.PutString(key + LEFT_MOUNT + i + RIGHT_MOUNT, aValue); i++; } for (; i < stringSetLength; i++) { // Remove any remaining values editor.Remove(key + LEFT_MOUNT + i + RIGHT_MOUNT); } } if (Build.VERSION.SdkInt < Build.VERSION_CODES.Gingerbread) { editor.Commit(); } else { editor.Apply(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); ISharedPreferences sharedPreferences = GetSharedPreferences("mypref", FileCreationMode.Private); string username = sharedPreferences.GetString("username", null); string password = sharedPreferences.GetString("password", null); int id = sharedPreferences.GetInt("user_id", -1); string fullname = sharedPreferences.GetString("fullname", null); Intent login = new Intent(this, typeof(LoginActivity)); if (username == null || password == null || id == -1) { StartActivity(login); } else { SQLLibrary library = SQLLibrary.getInstance(); User user = library.Login(username, password); if (user != null) { library.SetUser(user); Intent search = new Intent(this, typeof(DashboardActivity)); // search.PutExtra("com.csi4999.inline.EXTRA_USER_ID", id); // search.PutExtra("com.csi4999.inline.EXTRA_USER_FULLNAME", fullname); // search.PutExtra("com.csi4999.inline.EXTRA_EMAIL", username); StartActivity(search); } else { StartActivity(login); } } Finish(); }
private async void Crear_direccion() { if (direccion != "") { TextView campo_alias = FindViewById <TextView>(Resource.Id.direccion_alias); alias = campo_alias.Text; //Obtener id del cliente Context mContext = Application.Context; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(mContext); int cliente = prefs.GetInt("id", 0); //Actualizar cliente await core.CrearDireccion(cliente, alias, direccion, latitud, longitud); //Ir a direcciones Intent direcciones = new Intent(this, typeof(MisDireccionesActivity)); StartActivity(direcciones); } else { mensaje.Visibility = ViewStates.Visible; } }
/// <summary> /// Returns a stored geofence by its ID, or returns null if it's not found /// </summary> /// <returns>A SimpleGeofence defined by its center and radius, or null if the ID is invalid</returns> /// <param name="id">The ID of a stored Geofence</param> public SimpleGeofence GetGeofence(String id) { // Get the latitude for the geofence identified by id, or INVALID_FLOAT_VALUE if it doesn't exist (similarly for the other values that follow) double lat = mPrefs.GetFloat(GetGeofenceFieldKey(id, Constants.KEY_LATITUDE), Constants.INVALID_FLOAT_VALUE); double lng = mPrefs.GetFloat(GetGeofenceFieldKey(id, Constants.KEY_LONGITUDE), Constants.INVALID_FLOAT_VALUE); float radius = mPrefs.GetFloat(GetGeofenceFieldKey(id, Constants.KEY_RADIUS), Constants.INVALID_INT_VALUE); long expirationDuration = mPrefs.GetLong(GetGeofenceFieldKey(id, Constants.KEY_EXPIRATION_DURATION), Constants.INVALID_LONG_VALUE); int transitionType = mPrefs.GetInt(GetGeofenceFieldKey(id, Constants.KEY_TRANSITION_TYPE), Constants.INVALID_INT_VALUE); // If none of the values is incorrect, return the object if (lat != Constants.INVALID_FLOAT_VALUE && lng != Constants.INVALID_FLOAT_VALUE && radius != Constants.INVALID_FLOAT_VALUE && expirationDuration != Constants.INVALID_LONG_VALUE && transitionType != Constants.INVALID_INT_VALUE) { return(new SimpleGeofence(id, lat, lng, radius, expirationDuration, transitionType)); } // Otherwise return null return(null); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); userID = Intent.GetStringExtra ("id") ?? "-1"; mainPrefs = GetSharedPreferences("loginPrefs",FileCreationMode.Private); mainEditor = mainPrefs.Edit (); serviceNumer = mainPrefs.GetInt ("service_size", -1); categoryNumber = mainPrefs.GetInt ("category_size", 0); SetContentView (Resource.Layout.Main); tabHost = FindViewById<TabHost> (Android.Resource.Id.TabHost); tabHost.Setup (); for (int i = 0; i < categoryNumber; i++) { TabHost.TabSpec tabSpec; tabSpec = tabHost.NewTabSpec(mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower()); tabSpec.SetIndicator(mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower()); tabSpec.SetContent(new FakeContent(this)); tabHost.AddTab(tabSpec); } tabHost.SetOnTabChangedListener(this); setSelectedTabColor (); /*for(int i = 0; i < tabHost.TabWidget.ChildCount; i++) { View v = tabHost.TabWidget.GetChildTabViewAt(i); // Look for the title view to ensure this is an indicator and not a divider. v.SetBackgroundResource(Resource.Drawable.apptheme_tab_indicator_holo); }*/ viewPager = FindViewById<ViewPager> (Resource.Id.view); var adaptor = new ServiceBeaconAdapter (SupportFragmentManager); for (int i = 0; i < categoryNumber; i++) { adaptor.addFragmentView ((k, v, b) => { var view = k.Inflate (Resource.Layout.Page, v, false); var myText = view.FindViewById<TextView> (Resource.Id.textView1); myText.Text = mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower(); return view; }); } viewPager.Adapter = adaptor;//new ServiceBeaconAdapter (SupportFragmentManager); viewPager.SetOnPageChangeListener(this); beaconStatusLabel = FindViewById<TextView> (Resource.Id.beaconStatusLabel); beaconMgr.Bind (this); //myProcessedBeacons = new JavaDictionary<string,string>(); monitorNotifier.EnterRegionComplete += EnteredRegion; monitorNotifier.ExitRegionComplete += ExitedRegion; rangeNotifier.DidRangeBeaconsInRegionComplete += HandleBeaconsInRegion; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); userID = Intent.GetStringExtra ("id") ?? "-1"; mainPrefs = GetSharedPreferences("loginPrefs",FileCreationMode.Private); mainEditor = mainPrefs.Edit (); serviceNumer = mainPrefs.GetInt ("service_size", -1); SetContentView (Resource.Layout.Main); tabHost = FindViewById<TabHost> (Android.Resource.Id.TabHost); tabHost.Setup (); for (int i = 1; i <= 2; i++) { TabHost.TabSpec tabSpec; tabSpec = tabHost.NewTabSpec("Tab " + i); tabSpec.SetIndicator("Tab " + i); tabSpec.SetContent(new FakeContent(this)); tabHost.AddTab(tabSpec); } tabHost.SetOnTabChangedListener(this); viewPager = FindViewById<ViewPager> (Resource.Id.view); var adaptor = new ServiceBeaconAdapter (SupportFragmentManager); adaptor.addFragmentView ((i, v, b) => { var view = i.Inflate (Resource.Layout.Page, v, false); var myText = view.FindViewById<TextView> (Resource.Id.textView1); myText.Text = myText.Text + "1"; return view; }); adaptor.addFragmentView((i,v,b) => { var view = i.Inflate(Resource.Layout.Page,v,false); var myText = view.FindViewById<TextView> (Resource.Id.textView1); myText.Text = myText.Text + "2"; return view; }); viewPager.Adapter = adaptor;//new ServiceBeaconAdapter (SupportFragmentManager); viewPager.SetOnPageChangeListener(this); beaconStatusLabel = FindViewById<TextView> (Resource.Id.beaconStatusLabel); beaconMgr.Bind (this); //myProcessedBeacons = new JavaDictionary<string,string>(); monitorNotifier.EnterRegionComplete += EnteredRegion; monitorNotifier.ExitRegionComplete += ExitedRegion; rangeNotifier.DidRangeBeaconsInRegionComplete += HandleBeaconsInRegion; }