Questions tagged [android-service]

A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use.

A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Each service class must have a corresponding declaration in its package's AndroidManifest.xml. Services can be started with Context.startService() and Context.bindService().

Android Service Class Reference

Tutorials & Examples

6696 questions
2
votes
2 answers

Android service interactions

I have a list of tasks that are displayed inside a RecyclerView. For each task I present an activity containing: A play button that displays a chronometer when clicked A done button to say a task is complete and to stop the service bound to the…
2
votes
1 answer

When I use FLAG_ACTIVITY_SINGLE_TOP - onDestroy() keep my activity alive

When my service need to interact with the user it starts an activity: Intent i = new Intent(context, Ringer_intent.class); i.putExtra("PHONE_NUMBER",…
Ori
  • 53
  • 3
  • 8
2
votes
1 answer

Android - Handle global configuration changes

I'm writing a service that tracks system changes, meaning, I'm willing to track whenever a keyboard becomes visible / hidden for any application. To achieve the following task, i built a small Activity that launches a services public class…
igal k
  • 1,883
  • 2
  • 28
  • 57
2
votes
1 answer

Reason behind keeping bound services out of Background Execution Limits in Android Oreo

In Android Oreo why bound services still allowed whereas (Started Services & IntentServices) are not allowed. Suppose I have a bound service which I am binding in my oncreate() method of my activity and unbinding it in my ondestroy() method of my…
2
votes
1 answer

PhoneAuthProvider not working

Hello I am working with Firebase Authentication method of Phone Authentication but when I put that method that time PhoneAuthProvider given me error that not cannot resolve symbol: private void resendVerificationCode(String phoneNumber, …
2
votes
2 answers

Android - why the app crash when the service receive a call and the app is closed?

I am making an app that make something happen when the phone gets a call, so after a lot of searching I discover that I can use a BroadcastReceiver and a Service so I created a Service called PhoneStateService: import android.app.Service; import…
user8365522
2
votes
1 answer

Running an Android Service after every 20 sec using AlarmManager doesn't restart on killing the app from the app list

I am trying to run an Android Service which runs in background every 20 sec and send user's lat-long data to server for tracking. It works for the first time when I launch my application. Now If I click the Home Button, It still runs in the…
2
votes
2 answers

android broadcast receiver (call and sms received) not working in android nougat

android call and SMS broadcast receiver working perfectly till marshmallow 6.0, but in android nougat , it is not working when app is closed, and when app is in background, then its working fine in android nougat(N). please can anyone help me for…
2
votes
2 answers

Get continuous location using service even after app killed from recent drawer

I started Service from main activity like;- Intent intent = new Intent(this, MyLocationService.class); startService(intent); MyLocationService class looks like:- public class MyLocationService extends Service implements LocationListener, …
2
votes
2 answers

Using Service to share/persist data across Activities

I've recently been looking at options available to me for persisting data across Activities. I've searched a bit online and only found a few methods that other people seem to use. Some of them are - Intent Singleton class Disk Application What…
David Heisnam
  • 2,463
  • 1
  • 21
  • 32
2
votes
3 answers

Is it a good idea to bind on an Android service in the application class?

I have an Android foreground service that contains a map of session (key, session). In my activities, I receive a key and I want to get the session from the service. So I bind each of my activities to the service and I can ask the service to get my…
2
votes
1 answer

How to keep connection alive with Smack XMPP?

I am implementing a chat app with XMPP protocol and Smack library. I am making a connection to the server inside Service class. Everything works fine, sending and receiving messages, until some time passes and OS kills the app. How I can keep my…
Zookey
  • 2,637
  • 13
  • 46
  • 80
2
votes
0 answers

How to create service/broadcastreceiver which never force stop with task manager

I have an application in which i am taking device administrator and that application continuously connect to server to send phone data. But this background service is stopped after some days and also stopped when anybody kill with task manager…
user3997016
2
votes
1 answer

Do i need a wake lock to send data via network?

I have a location service. Time to time when the service receive new location i send all the past locations accumulated to the server. I don't really know how wake lock work under android, so do i need to keep a wake lock (or any think else?) when i…
user8371791
2
votes
1 answer

WindowManager.addView() causes BadTokenException

I'm trying to create an overlay window but when I try to add the view to the WindowManager, it gives me an exception. I have added the "SYSTEM_ALERT_WINDOW" permission and I have enabled "Draw over other apps" in app info. I'm calling this from…
1 2 3
99
100