Questions tagged [android-intentservice]

The IntentService class provides a straightforward structure for running an operation on a single background thread.

The IntentService class provides a straightforward structure for running an operation on a single background thread. This allows it to handle long-running operations without affecting your user interface's responsiveness. Also, an IntentService isn't affected by most user interface lifecycle events, so it continues to run in circumstances that would shut down an AsyncTask

An IntentService has a few limitations:

  • It can't interact directly with your user interface. To put its results in the UI, you have to send them to an Activity.
  • Work requests run sequentially. If an operation is running in an IntentService, and you send it another request, the request waits until the first operation is finished.
  • An operation running on an IntentService can't be interrupted.

However, in most cases an IntentService is the preferred way to simple background operations.

461 questions
1
vote
1 answer

Xamarin Android AndroidX.Core.Content.FileProvider.GetUriForFile NullReferenceException

Hi im having such problem with installation of downloaded APK file there is code where it occures with System.NullReferenceException: 'Object reference not set to an instance of an object.' var file = new Java.IO.File(filePath); if…
1
vote
0 answers

(Pending)intent opens SMS Application if File doesn't exist

I've got the following code: //gallery is going to get open if notification is clicked. Intent intent=new Intent(Intent.ACTION_VIEW,photoURI); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); PendingIntent pendingIntent =…
1
vote
1 answer

SyncAdapter to receive chat messages?

For my chat app I am looking for a good way to sync messages while the app is in background. At the moment I have a websocket. When the app comes to foreground, messages get synced. This makes the app looking laggy. Like WhatsApp I need a way to…
1
vote
1 answer

intent.getStringExtra is always "null"

This is how the string is added to intent.putExtra: final ListView listView = findViewById(R.id.userListView); final ArrayList usernames = new ArrayList<>(); listView.setOnItemClickListener(new AdapterView.OnItemClickListener()…
1
vote
0 answers

How to get an AlarmManager to run when the app is closed?

I am trying to set up an AlarmManager in my app that opens another app at a specific time. It works when my app is open and on the screen, but if I press the home button and send my app to the background, it does not work. How do I get an…
1
vote
2 answers

Intent Service works but class it calls to do work stops when app is closed

I have an IntentService called ReplyMessageIntentService in my app, and this service is responsible for receiving messages that comes from notification direct reply. The intent service does immediately calls a class SaveMessage that saves messages…
1
vote
0 answers

Trigger a Job on BOOT_COMPLETE in API > 26

I'm in the process of creating an app which displays a notification whenever a message (received via MQTT) arrives. I'd like this to happen regardless of whether the app is running or not. I've done a bit of research and found that I can register a…
1
vote
0 answers

Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground():

I know this is a duplicate problem but still, none of the answers worked for me. There are some devices in crashlytics that are causing this Fatal crash. Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not…
1
vote
1 answer

Negative priorities in intent filter in Android Manifest file

As per the android documentation, we can define a priority for the intent-filters in the Manifest file. The priority can be a integer with 0 being a default value. Also if we check the setPriority(int Priority) API, while describing the priority it…
1
vote
0 answers

Intent Service does not call onDestroy after Rescheduling & setIntentRedelivery is true

I'm running Intent service on a button click. And I want Intent Service to restart if it crashes during its execution. I have created an Intent Service and for it to restart automatically after crashing, I have setIntentRedelivery to true in service…
M Saif Ullah
  • 86
  • 2
  • 5
1
vote
0 answers

Use IntentService with AndroidViewModel

I need to perform some background calculation task in a project using MVVM design pattern. I have tried AsyncTask and IntentService in my ViewModel but with no success. The calculation process is working well, but I have problems in getting the…
1
vote
1 answer

How to fix error "Unable to instantiate service *<*.TimerIntentService> has no zero argument constructor"

I am setting up timer as a feature in my android application. App is based on fragments. It has just two activities and a lot of fragments, connected by navigation. I try implement timer using Intent service, but I have problem. App crashes on…
1
vote
0 answers

Android : Run service irrespective of app crash or working

I am working on the functionality to fetch logs of application and upload it to server. We are writing logs into file. What i need to do? We have used fabric(Currently Firebase crashlystics) for crash reporting. but some time lots of crashes are…
1
vote
1 answer

Does stopSelf() guarantee Service stopping (and HOW)? if so, is return required (in case stopSelf called internally)?

I Have questions about how Service and IntentService function. The points to ask about are below: Does calling stopSelf() manually in Service (or IntentService) guarantee the service to stop? If stopSelf() is called manually somewhere in the…
younes zeboudj
  • 856
  • 12
  • 22
1
vote
1 answer

Access Room database to update widget in onHandleIntent method of IntentService

I have a widget which I want to update every time I update my database and want to show the content from the database on the widget even when the app is not running. My db is implemented using Room, and the widget is updated using an…