Esempio n. 1
0
 public void CancelAlarm(Context context, long Id)
 {
     alarm         = (Android.App.AlarmManager)context.GetSystemService(Context.AlarmService);
     intent        = new Intent(context, typeof(NotifyManager));
     pendingIntent = Android.App.PendingIntent.GetBroadcast(context, Convert.ToInt32(Id), intent, Android.App.PendingIntentFlags.UpdateCurrent);
     alarm.Cancel(pendingIntent);
 }  //cancel old alarm
        /// <summary>
        /// The get expansion files.
        /// </summary>
        /// <returns>
        /// The get expansion files.
        /// </returns>
        private bool GetExpansionFiles()
        {
            bool result = false;

            try
            {
                // Build the intent that launches this activity.
                Intent launchIntent = Intent;
                var    intent       = new Intent(this, typeof(ExpansionDownloaderActivity));
                intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                intent.SetAction(launchIntent.Action);

                if (launchIntent.Categories != null)
                {
                    foreach (string category in launchIntent.Categories)
                    {
                        intent.AddCategory(category);
                    }
                }

                // Build PendingIntent used to open this activity when user
                // taps the notification.
                Android.App.PendingIntent pendingIntent = Android.App.PendingIntent.GetActivity(
                    this, 0, intent, Android.App.PendingIntentFlags.UpdateCurrent);

                // Always force download of LVL
                DownloadsDB.GetDB(this).UpdateMetadata(0, 0);
                // Request to start the download
                DownloaderServiceRequirement startResult = DownloaderService.StartDownloadServiceIfRequired(
                    this, pendingIntent, typeof(ExpansionDownloaderService));

                // The DownloaderService has started downloading the files,
                // show progress otherwise, the download is not needed so  we
                // fall through to starting the actual app.
                if (startResult != DownloaderServiceRequirement.NoDownloadRequired)
                {
                    InitializeDownloadUi();
                    result = true;
                }
            }
            catch (PackageManager.NameNotFoundException e)
            {
#if DEBUG
                Android.Util.Log.Debug(Tag, "Cannot find own package!");
#endif
                e.PrintStackTrace();
            }
#pragma warning disable 168
            catch (Exception ex)
#pragma warning restore 168
            {
                // ignored
#if DEBUG
                Android.Util.Log.Debug(Tag, "Exception: ", EdiabasLib.EdiabasNet.GetExceptionText(ex));
#endif
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Builds a PendingIntent that will display the main activity of the app. This is used when the
        /// user taps on the notification; it will take them to the main activity of the app.
        /// </summary>
        /// <returns>The content intent.</returns>
        private Android.App.PendingIntent BuildIntentToShowMainActivity()
        {
            Intent showMainActivityIntent = new Intent(this, GetType());

            showMainActivityIntent.SetAction(ActionShowMainActivity);
            Android.App.PendingIntent pendingIntent = Android.App.PendingIntent.GetService(this, 0, showMainActivityIntent, Android.App.PendingIntentFlags.UpdateCurrent);
            return(pendingIntent);
        }
Esempio n. 4
0
        }  //cancel old alarm

        public void ChangeIntent(Context context)
        {
            if (intent != null)
            {
                intent.RemoveExtra("message");

                // (WriteActivity)context.ApplicationContext.
                intent.PutExtra("message", Content);
                pendingIntent = Android.App.PendingIntent.GetBroadcast(context, Convert.ToInt32(Id), intent, Android.App.PendingIntentFlags.UpdateCurrent);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Builds a PendingIntent that will display the main activity of the app. This is used when the
        /// user taps on the notification; it will take them to the main activity of the app.
        /// </summary>
        /// <returns>The content intent.</returns>
        private Android.App.PendingIntent BuildIntentToShowMainActivity()
        {
            Intent notificationIntent = new Intent(this, typeof(ActivityMain));

            notificationIntent.SetAction(ActionMainActivity);
            //notificationIntent.SetFlags(ActivityFlags.SingleTop /*| ActivityFlags.ClearTask*/);
            notificationIntent.SetFlags(ActivityFlags.NewTask);
            notificationIntent.PutExtra(ActivityMain.ExtraStopComm, false);

            Android.App.PendingIntent pendingIntent = Android.App.PendingIntent.GetActivity(this, 0, notificationIntent, Android.App.PendingIntentFlags.UpdateCurrent);
            return(pendingIntent);
        }
 /// <summary>
 /// Starts a new activity for the user to buy an item for sale. This method
 /// forwards the intent on to the PurchaseObserver (if it exists) because
 /// we need to start the activity on the activity stack of the application.
 /// </summary>
 /// <param name="pendingIntent"> a PendingIntent that we received from Android Market that
 ///     will create the new buy page activity </param>
 /// <param name="intent"> an intent containing a request id in an extra field that
 ///     will be passed to the buy page activity when it is created </param>
 public static void buyPageIntentResponse(PendingIntent pendingIntent, Intent intent)
 {
     if (sPurchaseObserver == null)
     {
         if (Consts.DEBUG)
         {
             Log.Debug(TAG, "UI is not running");
         }
         return;
     }
     sPurchaseObserver.startBuyPageActivity(pendingIntent, intent);
 }
Esempio n. 7
0
        /// <summary>
        /// Builds a PendingIntent that will display the main activity of the app. This is used when the
        /// user taps on the notification; it will take them to the main activity of the app.
        /// </summary>
        /// <returns>The content intent.</returns>
        private Android.App.PendingIntent BuildIntentToShowMainActivity()
        {
            Intent showMainActivityIntent = new Intent(this, GetType());

            showMainActivityIntent.SetAction(ActionShowMainActivity);
            Android.App.PendingIntentFlags intentFlags = Android.App.PendingIntentFlags.UpdateCurrent;
            if (Build.VERSION.SdkInt >= BuildVersionCodes.S)
            {
                intentFlags |= Android.App.PendingIntentFlags.Mutable;
            }
            Android.App.PendingIntent pendingIntent = Android.App.PendingIntent.GetService(this, 0, showMainActivityIntent, intentFlags);
            return(pendingIntent);
        }
Esempio n. 8
0
        /// <summary>
        /// Builds the Notification.Action that will allow the user to stop the service via the
        /// notification in the status bar
        /// </summary>
        /// <returns>The stop service action.</returns>
        private NotificationCompat.Action BuildStopServiceAction()
        {
            Intent stopServiceIntent = new Intent(this, GetType());

            stopServiceIntent.SetAction(ActionStopService);
            Android.App.PendingIntent stopServicePendingIntent = Android.App.PendingIntent.GetService(this, 0, stopServiceIntent, 0);

            var builder = new NotificationCompat.Action.Builder(Resource.Drawable.ic_stat_cancel,
                                                                GetText(Resource.String.service_stop_comm),
                                                                stopServicePendingIntent);

            return(builder.Build());
        }
Esempio n. 9
0
        /// <summary>
        /// Builds the Notification.Action that will allow the user to stop the service via the
        /// notification in the status bar
        /// </summary>
        /// <returns>The stop service action.</returns>
        private NotificationCompat.Action BuildStopServiceAction()
        {
            Intent stopServiceIntent = new Intent(this, GetType());

            stopServiceIntent.SetAction(ActionStopService);
            Android.App.PendingIntentFlags intentFlags = 0;
            if (Build.VERSION.SdkInt >= BuildVersionCodes.S)
            {
                intentFlags |= Android.App.PendingIntentFlags.Mutable;
            }
            Android.App.PendingIntent stopServicePendingIntent = Android.App.PendingIntent.GetService(this, 0, stopServiceIntent, intentFlags);

            var builder = new NotificationCompat.Action.Builder(Resource.Drawable.ic_stat_cancel,
                                                                GetText(Resource.String.service_stop_comm),
                                                                stopServicePendingIntent);

            return(builder.Build());
        }
Esempio n. 10
0
        public void CancelAlarm(Context context)
        {
            //Shared = PreferenceManager.GetDefaultSharedPreferences(context);

            //PrefsEditor = Shared.Edit();
            alarm         = (Android.App.AlarmManager)context.GetSystemService(Context.AlarmService);
            intent        = new Intent(context, typeof(NotifyManager));
            pendingIntent = Android.App.PendingIntent.GetBroadcast(context, Convert.ToInt32(Id), intent, Android.App.PendingIntentFlags.UpdateCurrent);
            alarm.Cancel(pendingIntent);
            ContentValues cv = new ContentValues();

            cv.Put(Databasehelper.COLUMN_NOTIFY, 0);
            Db.Update(Databasehelper.TEXTTABLE, cv, "_id =?", new string[] { Id.ToString() });
            //cv.Put(Databasehelper.COLUMN_NOTIFY, 0);

            //Db.Update(Databasehelper.TEXTTABLE, cv, "_id = ?", new string[] { Id.ToString() });
            //PrefsEditor.Remove(Id.ToString());
            //PrefsEditor.Apply();
        }
Esempio n. 11
0
        private void SetAlarm_Click(object sender, EventArgs e)
        {
            Button setButton = (Button)sender;

            if (setButton.Text == Resources.GetString(Resource.String.auto_btn_set_alarm))
            {
                int hour, minute;
                hour   = tp.Hour;
                minute = tp.Minute;

                ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Context);
                ISharedPreferencesEditor editor = prefs.Edit();
                editor.PutInt(General.ALARM_HOUR, hour);
                editor.PutInt(General.ALARM_MINUTE, minute);
                editor.PutBoolean(General.ALARM_ACTIVE, true);
                editor.Apply();

                SetActiveAlarmText(true);

                General.ProgramNextAlarm(Context);

                Toast.MakeText(Context, Resource.String.auto_toast_alarm_set, ToastLength.Short).Show();
            }
            else
            {
                Intent i = new Intent(this.Context, typeof(AlarmBroadcastReceiver));
                Android.App.PendingIntent pi           = Android.App.PendingIntent.GetBroadcast(Context, 1, i, 0);
                Android.App.AlarmManager  alarmManager = (Android.App.AlarmManager)Context.GetSystemService(Context.AlarmService);

                // La cancela
                alarmManager.Cancel(pi);
                pi.Cancel();

                ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Context);
                ISharedPreferencesEditor editor = prefs.Edit();
                editor.PutBoolean(General.ALARM_ACTIVE, false);
                editor.Apply();
                SetActiveAlarmText(false);
            }
            HowLongToNext();
        }
Esempio n. 12
0
        public override void OnReceive(Context context, Intent intent)
        {
            Intent resultIntent;
            int    id = Convert.ToInt32(intent.GetLongExtra("_id", 0));

            databasehelper = new Databasehelper(context);

            Db = databasehelper.WritableDatabase;

            resultIntent = new Intent(context, typeof(WriteActivity));
            resultIntent.PutExtra("_id", id.ToString());



            ContentValues cv = new ContentValues();

            cv.Put(Databasehelper.COLUMN_NOTIFY, 0);
            Db.Update(Databasehelper.TEXTTABLE, cv, "_id= ?", new string[] { id.ToString() });
            Db.ExecSQL("VACUUM");
            Android.App.PendingIntent resultPendingIntent = Android.App.PendingIntent.GetActivity(context, id, resultIntent,
                                                                                                  Android.App.PendingIntentFlags.UpdateCurrent);
            NotificationCompat.Builder builder =
                new NotificationCompat.Builder(context, "ID")
                .SetSmallIcon(Android.Resource.Drawable.IcButtonSpeakNow)
                .SetContentTitle("Вам напоминание!")
                .SetContentText(intent.GetStringExtra("message"))
                .SetPriority((int)Android.App.NotificationPriority.Default)
                .SetContentIntent(resultPendingIntent)
                .SetAutoCancel(true)
            ;
            Android.App.NotificationManager manager = (Android.App.NotificationManager)context.GetSystemService(Context.NotificationService);

            Android.App.Notification notification = builder.Build();


            Multitools.createChannelIfNeeded(manager);
            manager.Notify(id, notification);
        }
 public Task RequestLocationUpdatesAsync(LocationRequest locationRequest, Android.App.PendingIntent pendingIntent)
 {
     return(RequestLocationUpdates(locationRequest, pendingIntent).AsAsync());;
 }
 public static async Task <Statuses> UnsubscribeAsync(this IMessages api, GoogleApiClient client, Android.App.PendingIntent pendingIntent)
 {
     return((await api.Unsubscribe(client, pendingIntent)).JavaCast <Statuses> ());
 }
 public Task <Android.Views.Display> StartRemoteDisplayAsync(CastDevice castDevice, string applicationId, int configPreset, Android.App.PendingIntent sessionEndedPendingIntent)
 {
     return(StartRemoteDisplay(castDevice, applicationId, configPreset, sessionEndedPendingIntent).AsAsync <Android.Views.Display>());
 }
 public Task ShowUserChallengeAsync(string accountType, Android.App.PendingIntent pendingIntent)
 {
     return(ShowUserChallenge(accountType, pendingIntent).AsAsync());
 }
 public static async Task <Statuses> AddGeofencesAsync(this IGeofencingApi api, GoogleApiClient client, IList <IGeofence> geofences, Android.App.PendingIntent pendingIntent)
 {
     return((await api.AddGeofences(client, geofences, pendingIntent)).JavaCast <Statuses> ());
 }
 public static async Task <Statuses> RequestActivityUpdatesAsync(this IActivityRecognitionApi api, GoogleApiClient client, long detectionIntervalMillis, Android.App.PendingIntent callbackIntent)
 {
     return((await api.RequestActivityUpdates(client, detectionIntervalMillis, callbackIntent)).JavaCast <Statuses> ());
 }
Esempio n. 19
0
 public static async Task <Statuses> AddAsync(this ISensorsApi api, GoogleApiClient client, Request.SensorRequest request, Android.App.PendingIntent intent)
 {
     return((await api.Add(client, request, intent)).JavaCast <Statuses> ());
 }
 public Task RemoveLocationUpdatesAsync(Android.App.PendingIntent pendingIntent)
 {
     return(RemoveLocationUpdates(pendingIntent).AsAsync());
 }
Esempio n. 21
0
 public static async Task <Statuses> UnregisterForSessionsAsync(this ISessionsApi api, GoogleApiClient client, Android.App.PendingIntent intent)
 {
     return((await api.UnregisterForSessions(client, intent)).JavaCast <Statuses> ());
 }
 public Task AddGeofencesAsync(GeofencingRequest geofenceRequest, Android.App.PendingIntent pendingIntent)
 {
     return(AddGeofences(geofenceRequest, pendingIntent).AsAsync());
 }
 public Task RemoveGeofencesAsync(Android.App.PendingIntent pendingIntent)
 {
     return(RemoveGeofences(pendingIntent).AsAsync());
 }
 public Task RemoveActivityUpdatesAsync(Android.App.PendingIntent callbackIntent)
 {
     return(RemoveActivityUpdates(callbackIntent).AsAsync());
 }
 public static async Task <Statuses> RemoveActivityUpdatesAsync(this IActivityRecognitionApi api, GoogleApiClient client, Android.App.PendingIntent callbackIntent)
 {
     return((await api.RemoveActivityUpdates(client, callbackIntent)).JavaCast <Statuses> ());
 }
 public Task RequestActivityUpdatesAsync(long detectionIntervalMillis, Android.App.PendingIntent callbackIntent)
 {
     return(RequestActivityUpdates(detectionIntervalMillis, callbackIntent).AsAsync());
 }
 public static async Task <Statuses> RequestLocationUpdatesAsync(this IFusedLocationProviderApi api, GoogleApiClient client, LocationRequest request, Android.App.PendingIntent callbackIntent)
 {
     return((await api.RequestLocationUpdates(client, request, callbackIntent)).JavaCast <Statuses> ());
 }
 public static async Task <Statuses> UnregisterDataUpdateListenerAsync(this IHistoryApi api, GoogleApiClient client, Android.App.PendingIntent pendingIntent)
 {
     return((await api.UnregisterDataUpdateListener(client, pendingIntent)).JavaCast <Statuses> ());
 }
 public static async Task <Statuses> RemoveGeofencesAsync(this IGeofencingApi api, GoogleApiClient client, Android.App.PendingIntent pendingIntent)
 {
     return((await api.RemoveGeofences(client, pendingIntent)).JavaCast <Statuses> ());
 }
Esempio n. 30
0
        void OnClickAccept(object sender, EventArgs e)
        {
            if ((DateTime.Now.Date == Date && (DateTime.Now.Hour > Hour || DateTime.Now.Hour == Hour && DateTime.Now.Minute >= Minute)) || DateTime.Now.Date > Date) //If current date, check hour is not less current hour, and if current date and hour, check minute
            {
                Toast toast = Toast.MakeText(Context, "Нельзя установить прошедшее время или дату.", ToastLength.Short);
                toast.Show();
            }
            else
            {
                Id = SqlHelper.SaveText(Editable, Args);

                if (Args == null)
                {
                    Args = new Bundle();
                    Args.PutString("_id", Id.ToString());
                }
                cursor  = Db.RawQuery(("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + Id.ToString()), null);
                Content = Multitools.GetNameNote(Editable.ToString().Split("\n")[0], cursor);
                Calendar calendar = Calendar.Instance;

                calendar.Set(CalendarField.Year, Date.Year);
                calendar.Set(CalendarField.Month, Date.Month - 1);
                calendar.Set(CalendarField.DayOfMonth, Date.Day);
                calendar.Set(CalendarField.HourOfDay, Hour);
                calendar.Set(CalendarField.Minute, Minute);
                calendar.Set(CalendarField.Second, 0);
                NotifyManager notify = new NotifyManager();
                alarm  = (Android.App.AlarmManager)Context.GetSystemService(Context.AlarmService);
                intent = new Intent(Context, typeof(NotifyManager));

                intent.PutExtra("_id", Id);
                intent.PutExtra("message", Content);
                //ChangeIntent(Context);
                pendingIntent = Android.App.PendingIntent.GetBroadcast(Context, Convert.ToInt32(Id), intent, Android.App.PendingIntentFlags.UpdateCurrent);



                if (Convert.ToInt32(Build.VERSION.Sdk) >= 19)
                {
                    alarm.SetExact(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }
                else
                {
                    alarm.Set(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }

                ContentValues cv = new ContentValues();
                cv.Put(Databasehelper.COLUMN_NOTIFY, 1);
                cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.START_ID, uniqueId);
                //cv.Put(Databasehelper.NEW_ID, Id); //While id is identific

                Db.Update(Databasehelper.TEXTTABLE, cv, "_id=?", new string[] { Id.ToString() });
                //PrefsEditor.PutBoolean(Id.ToString(), true);
                //PrefsEditor.Apply();


                Dialog.Cancel();
            }
        }