foreground-service

How To Start An Activity From Background in Android 10?

故事扮演 提交于 2020-02-23 08:59:05
问题 I am building an android app where I need to start an activity from background. I am using a ForegroundStarter which extends Service for accomplishing this. I have an activity Adscreen.class which I need to run from my Foreground service. The activity Adscreen.class works fine(starts from background) on all Android versions except Android 10. ForeGroundStarter.class public class ForeGroundStarter extends Service { @Nullable @Override public IBinder onBind(Intent intent) { return null; }

locationListener doesn't work after 30 seconds on foreground service

泪湿孤枕 提交于 2020-02-22 06:30:27
问题 I have created a service which finds and then stores the user's coordinates in an SQLite database. public class GPS_Service extends Service { DatabaseHelper myDb; private LocationListener locationListener; private LocationManager locationManager; private String latitude, longitude; @Override public void onCreate() { super.onCreate(); myDb = new DatabaseHelper(this); } @SuppressLint("MissingPermission") @Override public int onStartCommand(Intent intent, int flags, int startId) { Intent

Is it possible to put a foreground service notification in a notification channel with IMPORTANCE_MIN?

萝らか妹 提交于 2020-02-21 09:58:51
问题 I am currently working on transitioning an application to Android O, and I am currently working on notification channels. I have made different channels with different importance levels and since the application has a foreground service that has to run at all times until we transition to a new architecture (more push oriented), I thought about putting that notification in a channel that has its importance set as IMPORTANCE_MIN , so that it is there, but it doesn't bother the user, and doesn't

Is it possible to put a foreground service notification in a notification channel with IMPORTANCE_MIN?

人走茶凉 提交于 2020-02-21 09:55:42
问题 I am currently working on transitioning an application to Android O, and I am currently working on notification channels. I have made different channels with different importance levels and since the application has a foreground service that has to run at all times until we transition to a new architecture (more push oriented), I thought about putting that notification in a channel that has its importance set as IMPORTANCE_MIN , so that it is there, but it doesn't bother the user, and doesn't

Is it possible to put a foreground service notification in a notification channel with IMPORTANCE_MIN?

拜拜、爱过 提交于 2020-02-21 09:55:18
问题 I am currently working on transitioning an application to Android O, and I am currently working on notification channels. I have made different channels with different importance levels and since the application has a foreground service that has to run at all times until we transition to a new architecture (more push oriented), I thought about putting that notification in a channel that has its importance set as IMPORTANCE_MIN , so that it is there, but it doesn't bother the user, and doesn't

Android service not working when phone is idle / dozing / locked

前提是你 提交于 2020-02-21 06:17:31
问题 Good evening, I've been trying to achieve something for several days now and I literally don't know what else to try, I've basically tried everything I found online and it still doesn't work but I have the feeling that once I find the solution it must be something quite simple. I'm working on a bigger project, but here I'm just trying to get a very simple example to work which I can later adapt to my project. What I want to do I want to have a counter add +1 every second for 1200 seconds (20

Android service not working when phone is idle / dozing / locked

爱⌒轻易说出口 提交于 2020-02-21 06:15:19
问题 Good evening, I've been trying to achieve something for several days now and I literally don't know what else to try, I've basically tried everything I found online and it still doesn't work but I have the feeling that once I find the solution it must be something quite simple. I'm working on a bigger project, but here I'm just trying to get a very simple example to work which I can later adapt to my project. What I want to do I want to have a counter add +1 every second for 1200 seconds (20

A foreground service gets killed and notification gets removed when app is swiped from recent apps

别来无恙 提交于 2020-01-22 20:11:47
问题 I have a foreground-service with notification. When the app is swiped away from recent apps tray, service gets killed and notification also gets removed. Here is the code for my service VoiceService.class : @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { showNotification(); Toast.makeText(this, "Service Started!", Toast.LENGTH_SHORT).show(); return START_STICKY; } private void showNotification() { new

android displaying multiple activity in saved state when notification click

可紊 提交于 2020-01-17 04:56:29
问题 I have a notification on my app. It works in foreground well. When i`m in a other activity and press home button after that i click notification. It opens given activity, but i need to display previous activity in a saved state. Notification note = new Notification(R.drawable.service_state_0, getResources().getText(R.string.serviceStarted), System.currentTimeMillis()); Intent i = new Intent(this, StartingActivity_.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE

Context.startForegroundService() did not then call Service.startForeground() - still a problem

会有一股神秘感。 提交于 2020-01-13 18:25:53
问题 After checking the google issue and a lot of other issues on SO, I came to the solution I added at the bottom. What I take care of is following: in onCreate AND in onStartCommand I make sure to move the service to the foregorund (if it is not already in the foreground) I don't simply stop a service, I do this with an extra command that I send to the onStartCommand handler to make sure, that the service is not stopped while it's started (eventually before it could finish going to the