background-service

How to run clock timer in background on flutter?

被刻印的时光 ゝ 提交于 2020-05-28 04:41:26
问题 I am try to create a timer app which have multiple countdown timer for different task. Issue, i am facing is that, if i start one timer, and press back button, timer stops. So i want, that timer to run till either it is being paused or timer ends and alerts the user or app is destroyed.Help me how can i do this using Flutter? Also i using sql-lite to store all timers. 回答1: Ah, background tasks! Dart (the language Flutter uses) is single-threaded . What does single-threaded mean? Single

Xamarin service - run according to a time schedule

主宰稳场 提交于 2020-05-17 07:42:24
问题 I am developing an app built on this example: https://github.com/xamarin/mobile-samples/tree/master/BackgroundLocationDemo The example works and the location updates are coming in as expected. However, Android keeps showing an notification that the service is running and draining battery. Now, all my users have a defined working schedule (list of Start to End DateTime per day e.g 8am-1pm, 4pm-8pm), and I want that the service is only running between those working times. This means that I need

Exception thrown from task is swallowed if thrown after 'await'

送分小仙女□ 提交于 2020-04-11 02:06:09
问题 I'm writing a background service using .net's HostBuilder. I have class called MyService that implements BackgroundService ExecuteAsync method and i encountered some weird behavior there. Inside the method i await a certain task and any exception thrown after the await is swallowed but an exception that is thrown before the await terminates the process. I looked online in all sorts of forums (stack overflow, msdn, medium) but I could not find an explanation for this behavior. public class

While Unit Testing a .Net core 3.1 Background Service, unable to resolve IConfiguration

亡梦爱人 提交于 2020-03-04 07:42:05
问题 I'm trying to write unit test case for the BackgroundService Worker.cs . I have read Stack Overflow Question But still I get the error that "Unable to resolve service for type 'Microsoft.Extensions.Configuration.IConfiguration' while attempting to activate 'AutoClueArchiver.Worker'. public WorkerTests() { _config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .AddJsonFile("appsettings.Development.json", true, true) .AddJsonFile("appsettings.local.json", true, true)

Start App From Service in BackGround in oreo and newer

こ雲淡風輕ζ 提交于 2020-02-05 04:28:28
问题 my goal is show an activity in every where(even lock screen) on a specific time. i could in previous android versions until Oreo do this work , but after Oreo Google change the methods, "if you want to display a view on lockScreen use "Activity.this.setShowWhenLocked(true);" :Google says. then i have to create an activity and only use a service wasn't enough. My Solution : i use AlarmManger to run a service in background on a specific time, that service start my activity(my goal). Problem :

Why so slow Android service restarting with START_STICKY?

浪子不回头ぞ 提交于 2020-01-24 08:50:06
问题 I have a background service, and I am doing all the operations on this service. The service is working with activities at times. But if the application closes, the service restart with START_STICKY ; It works correctly, but sometimes it takes a long time to restart, like more than a minute. @Override public void onCreate() { SocketIOConnect(); super.onCreate(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } How do I reduce the restart

Send JSON data from a service to UI in Android

陌路散爱 提交于 2019-12-30 14:17:21
问题 The requirement is : I have a background service and in that service I am doing a REST call to get a JSON data. I want to send the JSON data to UI and update contents. One method I can use i.e. store the entire JSON string in SharedPreferences and retrieve in UI but I don't think that's efficient. Any idea guys ? I have added a Handler in UI to update elements but I am not that familiar in using it. Sample REST call code : DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost

Send JSON data from a service to UI in Android

狂风中的少年 提交于 2019-12-30 14:17:13
问题 The requirement is : I have a background service and in that service I am doing a REST call to get a JSON data. I want to send the JSON data to UI and update contents. One method I can use i.e. store the entire JSON string in SharedPreferences and retrieve in UI but I don't think that's efficient. Any idea guys ? I have added a Handler in UI to update elements but I am not that familiar in using it. Sample REST call code : DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost

Sends SMS in Background when Power Button is pressed

送分小仙女□ 提交于 2019-12-25 19:33:35
问题 Is there a way to tell my app to do something while it's running in the Background? What i try to do is to send a sms when i press the Power Button. This is what i wrote and it works currently while i'm inside the app: public boolean onKeyDown(int keyCode, KeyEvent event) { startService(new Intent(this, BackgroundService.class)); if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, "Ich brauche Hilfe!

Sends SMS in Background when Power Button is pressed

▼魔方 西西 提交于 2019-12-25 19:32:57
问题 Is there a way to tell my app to do something while it's running in the Background? What i try to do is to send a sms when i press the Power Button. This is what i wrote and it works currently while i'm inside the app: public boolean onKeyDown(int keyCode, KeyEvent event) { startService(new Intent(this, BackgroundService.class)); if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, "Ich brauche Hilfe!