android-service

Android - How is it possible, that a service keeps running after the Activity has been shut down?

末鹿安然 提交于 2019-12-20 21:01:08
问题 I am a bit confused about how services function, notably these two things: From http://developer.android.com/guide/topics/fundamentals/services.html : A service is "started" when an application component (such as an activity) starts it by calling startService(). Once started, a service can run in the background indefinitely, even if the component that started it is destroyed. and: Caution: A service runs in the main thread of its hosting process—the service does not create its own thread and

Detecting Android L Battery Saver

拈花ヽ惹草 提交于 2019-12-20 19:56:30
问题 One of the new features of Android L is a battery saver that kicks in at 15%. Is there some way to detect when this is active, so my app will respond correctly? http://www.technobuffalo.com/2014/07/02/android-l-project-volta-battery-life/ I would like my app to get a callback from the operating system when the this mode is active so I can stop background services. If there is no callback, I could make a background process query for the battery level, but that seems wasteful. I also do not

How to Add our own System Service in Android Framework?

半城伤御伤魂 提交于 2019-12-20 18:08:15
问题 I am new to android and i have been analyzing the android source code to understand how the System services are implemented. My Question is am I able to create my own System Service and add it to the framework so that all the applications should be Able to access my service. Any comments/Code snippets would be helpful. Thanks to the Replier in advance. 回答1: public class MyService extends Service { private static MyService instance = null; public static boolean isInstanceCreated(){ return

How to Add our own System Service in Android Framework?

谁说胖子不能爱 提交于 2019-12-20 18:08:05
问题 I am new to android and i have been analyzing the android source code to understand how the System services are implemented. My Question is am I able to create my own System Service and add it to the framework so that all the applications should be Able to access my service. Any comments/Code snippets would be helpful. Thanks to the Replier in advance. 回答1: public class MyService extends Service { private static MyService instance = null; public static boolean isInstanceCreated(){ return

Calling setVolumeControlStream from a Service

徘徊边缘 提交于 2019-12-20 17:35:14
问题 I need to call setVolumeControlStream from a service that plays some sound via STREAM_SYSTEM . Obviously in an Activity that is no problem, but how can I do this with a service? 回答1: From the looks of it, this isn't possible the way you are trying to do it. As said in the android reference The suggested audio stream will be tied to the window of this Activity Hence with a service that has no activity, there is no window to tie the audio stream to. However, It looks like you should be able to

Draw an Android canvas on top of all applications?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 15:42:08
问题 I suspect this isn't possible, given the nature of Android, but is there a way to create a view of sorts (perhaps using a Canvas object?) that is shown on top of all applications? My intent for this project is not malicious. I have created some simple Color Filter software for Windows that simply adds a window on top of all windows, which is filled with a user-chosen color, and has a low opacity. This adds a light tint to the screen which helps users with Scoptopic Sensitivity Syndrome use a

Running Android TTS in a Service

拈花ヽ惹草 提交于 2019-12-20 14:21:57
问题 I'm trying to get Android's TTS to run inside a service, but I have no idea why it isn't working, it compiles, doesn't crash, but it just doesn't work. The Toast notification do work though. package alarm.test; import android.app.Service; import com.google.tts.TextToSpeechBeta; import android.content.Intent; import android.os.IBinder; import android.widget.Toast; public class MyAlarmService extends Service { private TextToSpeechBeta myTts; private TextToSpeechBeta.OnInitListener

onTaskRemoved of a Android Service is never being called ! Why?

丶灬走出姿态 提交于 2019-12-20 12:43:50
问题 I am stuck with a issue from last 2 days, I want to hit a api and show user a Toast when user swipe off the app from Background Task, I found that from service it is possible as onTaskRemoved is called when app is removed from background. Code : MyService.java public class MyService extends Service { private static final String TAG = MyService.class.getSimpleName(); Handler mHandler; @Override public void onCreate() { super.onCreate(); mHandler = new Handler(); } @Nullable @Override public

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

╄→гoц情女王★ 提交于 2019-12-20 12:32:10
问题 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

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

白昼怎懂夜的黑 提交于 2019-12-20 11:36:54
问题 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. 回答1: If