コード例 #1
0
        public override void OnCreate()
        {
            base.OnCreate();
            Log.Info(TAG, "OnCreate");

            tsumTsumDatabaseManager = new TsumTsumDatabaseManager();

            StartService(new Intent(this, typeof(TsumTsumNotificationListener)));
        }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            sortingSpinner = FindViewById <Spinner>(Resource.Id.spinner1);

            tsumTsumDatabaseManager   = new TsumTsumDatabaseManager();
            tsumTsumBroadcastReceiver = new TsumTsumNotifcationBroadcastReceiver();

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            SetActionBar(toolbar);
            ActionBar.Title = GetString(Resource.String.ApplicationNameShort);

            sortingSpinner.ItemSelected += delegate
            {
                Settings.SetInt("sortingType", sortingSpinner.SelectedItemPosition);
                UpdateHeartView();
            };

            StartNotificationServiceIfNotRunning();

            if (!IsNotificationPermissionSet())
            {
                CreateAlert(
                    "No Permission",
                    "The required permissions are not set, do you want to set the setting now?",
                    "Yes",
                    (object sender, DialogClickEventArgs args) => { StartActivityForResult(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"), 0); }, // BEFORE: Android.Provider.Settings.ActionNotificationListenerSettings
                    "No",
                    (object sender, DialogClickEventArgs args) => { } // Deliberately empty!
                    );
            }

            CheckVersion(null, () =>
            {
                CreateAlert(
                    "New version available",
                    "A new version of the app is available, do you want to download it now?",
                    "Yes",
                    (object sender, DialogClickEventArgs args) => { StartActivity(new Intent(Intent.ActionView, global::Android.Net.Uri.Parse("http://tsumtsumhearttracker.pleduc.nl/download/newest/nl.pleduc.TsumTsumNotificationTracker-Signed.apk"))); },
                    "No",
                    (object sender, DialogClickEventArgs args) => { } // Deliberately empty!
                    );
            });

            Notification.Builder notificationBuilder = new Notification.Builder(this);
            notificationBuilder.SetContentTitle("Test");
            notificationBuilder.SetContentText("Test2");
            notificationBuilder.SetSmallIcon(Resource.Drawable.Icon);
            Notification notification = notificationBuilder.Build();
        }