コード例 #1
0
ファイル: Ads.cs プロジェクト: TOgburn/MonoGame-Snake
        protected int LoadSavedAdTime()
        {
            string loaded_ad_time = SaveDataHandler.LoadData(Ads.AdTimeSavePath);

            if (loaded_ad_time != null)
            {
                Debug.WriteLine("Ads::LoadSavedAdTime() - loaded_ad_time = " + loaded_ad_time);
                return(int.Parse(loaded_ad_time));
            }

            this.SaveCurrentAdTime(0);
            return(0);
        }
コード例 #2
0
ファイル: AndroidAds.cs プロジェクト: TOgburn/MonoGame-Snake
        private string GetAdvertiserID()
        {
            string id = null;
            var    cr = Application.Context.ContentResolver;

            // If do not track is on return empty advertiser id
            if (this.GetDoNotTrack() == 1)
            {
                return("00000000-0000-0000-0000-000000000000");
            }

            // First try to get the advertising_id (from on FireTV) if available
            try {
                id = Android.Provider.Settings.Secure.GetString(cr, "advertising_id");
            } catch {}

            // Next use android_id if available
            if (string.IsNullOrWhiteSpace(id))
            {
                try {
                    id = Android.Provider.Settings.Secure.GetString(cr, Android.Provider.Settings.Secure.AndroidId);
                } catch {}
            }

            // Next use Serial if available (exists on API Level 9)
            if (string.IsNullOrWhiteSpace(id))
            {
                id = Build.Serial;
            }

            // Finally if we still don't have an ad id generate a uuid and save it to file.
            if (string.IsNullOrWhiteSpace(id))
            {
                id = SaveDataHandler.LoadData(AndroidAds.CustomGUIDSavePath);
                if (string.IsNullOrWhiteSpace(id))
                {
                    id = Guid.NewGuid().ToString();
                    SaveDataHandler.SaveData(id, AndroidAds.CustomGUIDSavePath);
                }
            }

            return(id);
        }