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
1 answer

why is mConnection.onServiceConnected method not called

public class DeviceScanActivity extends AppCompatActivity/*ListActivity*/ { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mHandler = new…
mithun
  • 121
  • 11
2
votes
2 answers

Android: AsyncTask more priority than Service

I have a Service and AsyncTask running at the same time, Inside the service, storing the data in the server takes place, In AsyncTask, getting data from a different source and updating UI takes place. UI doesn't get updated until the the task inside…
2
votes
0 answers

How to create an android app that close on shake events?

I want to create an app that which get close whenever the device shakes. Can anyone explain how to do that? I have an idea that it requires to create a service that runs in background, but I am struggling with actual coding and don't know how to do…
anshul
  • 144
  • 2
  • 12
2
votes
0 answers

Using websocket connection inside job service (for Oreo+)

Our project uses websocket connection to sync data. Due to the limitations in Oreo, we aren't able to use service in background We tried to move our websocket connection to a job service. The service will be invoked by the system and job service…
2
votes
1 answer

Keep JobIntentService running with async task inside

I want to develop Text-To-Speech (TTS) feature in my app. It must be implemented inside Service, because user may leave "details" Activity and get back to "main" Activity or even leave my app, and it should still speak out loud text. Since Oreo…
snachmsm
  • 17,866
  • 3
  • 32
  • 74
2
votes
1 answer

Android Service Losing an ArrayList

Edit: here's the source on PasteBin. I feel like I might need to just redesign the entire Service.. :( I'm the developer of RingPack. The basic idea is that there is a Service launched in the background that takes care of switching the ringtone out…
Weston
  • 1,882
  • 1
  • 20
  • 26
2
votes
1 answer

Huawei P20 Lite killing a foreground service in Oreo

I am implementing an app, that has to do some heavy sensor(even with location) data collection while user does some activity. To do this, when user clicks the start collection, I create a foreground service to ensure continuous collection of the…
Viktor
  • 521
  • 1
  • 4
  • 17
2
votes
1 answer

Waiting till phone screen gets on

What I want: I am developing one app where I want to display dialog / popup on incoming call. I have observed in log that there is slight delay between my activity start on incoming call and phone screen getting on. First activity gets fired and…
PeterB
  • 313
  • 4
  • 19
2
votes
1 answer

Keep broadcast receiver running when activity and/or app is closed?

I have an activity where I can tap a button to start a BroadcastReceiver, which listens for changes of the wifi connection. Now when the activity is showing or I leave the app (press the home button) while the activity is showing the receiver works…
2
votes
3 answers

onStartCommand is calling only once in service android?

i have a simple service need to run in background.below is the code for the service.i want to run the code in onStartCommand repeatedly simply for test purpose i displayed toast.but Toast also calling only once import…
Gaju Kollur
  • 2,046
  • 5
  • 23
  • 47
2
votes
1 answer

Custom Service Notification Styling no longer works in Oreo

Before Oreo using a custom service notification with custom actions and styling does work. Now while updating to NotificationChannel's I'm getting a default notification saying 'Tap for more information or to stop the app'. Yet I'm finding no…
Deukalion
  • 2,516
  • 9
  • 32
  • 50
2
votes
0 answers

Relationship between process and service

I have recently encountered a problem where sometimes accessing a singleton from a background Service threw a NullPointerException. The singleton instance is constructed in the launcher activity and is guaranteed to not be null for the duration of…
Shawn Li
  • 419
  • 3
  • 17
2
votes
1 answer

my AlarmService go off for only 3 sec

i'm using alarm manger to set and alarm that's go off in exact time in day using service but it only run the mediaplayer for 3 sec and terminate the service , if i swipe the app while alarm song is running the service terminate // when i used…
2
votes
2 answers

how to wait in "for" loop of service until uploadingTask is Complete?

I have written program similar to below mention program. public class UploadingService extends Service { public UploadingService() { } @Override public int onStartCommand(Intent intent, int flags, int startId) { for(int i = 0;…
Shiva.AK
  • 29
  • 8
2
votes
1 answer

Communication between Activity and Service causes memory leak

In my application I have a (background) Service which runs in its own process. To communicate with other components I defined some AIDL interfaces: interface MyService { void addOnChangeListener(ServiceChangedListener listener); void…
Cilenco
  • 6,951
  • 17
  • 72
  • 152