android-service

Show a notification only if Activity is not showing

血红的双手。 提交于 2019-12-03 03:04:01
I have a background task I would like to handle. The thing is that when the task completes, I would like to call a new Activity to show the result to the user, only if my main Activity is showing, otherwise I would like to send just a notification so the user can see that the action completed, and be able to open it whenever he likes. I was thinking of using a service to handle the start and termination of the background task and broadcast a message when it finishes, but in this case I have no option to know whether the Activity was shown or the broadcast was not processed and I should send a

What role an Android Service should play in the MVP pattern?

让人想犯罪 __ 提交于 2019-12-03 02:52:46
I am developing an Android app that does Human Activity Recognition. It basically works like that - Service constantly reads the accelerator data and stores the recognized activity (i.e. Walking, running) in a database. The user can see all of the recognized activities in an ListView in activity (accesses the database). Every User table in the database has a pa_goal (physical activity goal) field which the Service reads from the database and does some checks. The user, of course, can change this goal from an activity. Since I will be implementing the MVP architectural pattern. I am unsure

How do I implement a BroadcastReceiver in a Service Class in Android?

大城市里の小女人 提交于 2019-12-03 00:53:08
I need to implement BroadcastReceiver in a Service class I have created: public class MyService extends Service in this class I have to implement a Simulation of Download by using Thread - Sleep when the user presses the button in the MyActivity Class which implements sendBroadcas(). I cannot extends the Service class to BroadcastReceiver as it is already extendes to Service. Can anyone help me to figure it out how to implement this mechanism? thanks Have the BroadcastReceiver as a top-level class or as an inner class in your service. And get a reference of the receiver in your service. Like

how to call an activity when getting incoming call.

瘦欲@ 提交于 2019-12-03 00:47:46
Hi all i want to invoke a my own activity over the default incoming call activity.. i have done this with using broadcast receivers i am invoking my activity when getting incoming call. but it is working fine for first time from second time when i get incoming call then default incoming call activity is coming over my activity . i don't know what is the problem can any one please help me .. Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.satish.service" android:versionCode="1" android:versionName="1.0" > <uses

Why does my Android service get restarted when the process is killed, even though I used START_NOT_STICKY?

人走茶凉 提交于 2019-12-03 00:10:15
问题 My app uses a pattern where I start a service with Context#startService() as well as bind to it with Context#bindService(). This is so that I can control the lifetime of the service independently from whether any clients are currently bound to it. However, I noticed recently that whenever my app is killed by the system, it soon restarts any services that were running. At this point the service will never be told to stop, and this is causing battery drain whenever it happens. Here's a minimal

Is it possible to have a AlarmManager inside a Service class?

核能气质少年 提交于 2019-12-02 23:49:19
问题 For example my app, it starts and runs the service(which is meant to check the database for new messages) but as far as I know you can have a AlarmManager to keep opening the Service if so is not opened. But can you have a AlarmManager inside the Service class to keep on checking for new message in the database? Instead of re-opening the Service class just keep checking the database? I want to know if it is possible to have a AlarmManager inside the Service class to keep checking the database

Getting I/art: Explicit concurrent mark sweep GC freed

好久不见. 提交于 2019-12-02 23:23:22
I'm starting a service => background service, And starting a check for files in "new Thread", In the log i'm getting the following, the service/app gets paused . Log : I/art: Explicit concurrent mark sweep GC freed 25935(1686KB) AllocSpace objects, 13(903KB) LOS objects, 39% free, 13MB/22MB, paused 649us total 43.569ms It's just a scan for files in MyData in SDcard, which contain a bunch of pics ( about 20 pics ) . **Scan = Getting the pics names and saving them to String . All this means is that the garbage collector is doing its job and freeing up memory. If you are seeing this frequently

How Google calendar or Instagram make their apps all the time up and running even after force stop

[亡魂溺海] 提交于 2019-12-02 22:37:15
Looks like force stop should prevent app from running and it's even disable all app's alarms. However I found that notification in Google Calendar still shown fine even after force stop, and I all the time see Instagram app running, even when I kill it, it's just restart automatically and it's once again there. So, what is a way to make app running constantly? I'm doing app with reminders and need to show notifications in specific time, regardless how app was previously closed before. If you start a service in Application Class than your service will be always running even though if a user

Bind service to activity or fragment?

末鹿安然 提交于 2019-12-02 21:35:27
I am working on a music player app. I have a main activity which has multiple fragments, each displaying songs on the device album wise, artist wise etc.. I have a music service which handles all the playback and other stuff. What I'm confused about is the binding of this service with various fragments I have. Right now I'm binding the main activity and each fragment individually with the service and its working pretty much fine. But I was wondering if this is really the best practice? Is there any way to just bind the main activity with the service and then some how use it in its child

How to create an android app that activates on shake events when screen locked? [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-02 21:16:49
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. I want to create an app that **starts the Main activity whenever the device shakes, even when screen locked. 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 it. To create an app which is sensitive to shake event: A. In manifest - register a boot receiver. It will make sure your app will always