android-service

get last Call on CallLog using a Service

假如想象 提交于 2019-12-22 01:17:23
问题 I'm doing a program to send the CallLog to a Server, I created a Service that makes a poll of the telephone status with the following method. This method is called onCreate. private void pollForCallStatus() { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Log.d("Poll", Integer.toString(telephonyManager.getCallState())); switch (telephonyManager.getCallState()){ case TelephonyManager.CALL_STATE_RINGING: Log.d("CallService", "ringing"); break; case TelephonyManager

Best practices of notifying UI components from AsyncTask or service

醉酒当歌 提交于 2019-12-22 00:02:14
问题 I've been reading to use AsyncTask class to do shorter background operations, and services for long lasting operations. So what are the best practices in Android to notify UI about changes in background processes when using AsyncTask class? Should I use classic MVC model and create a listener (preferably in class extending Application class) or is there a standart way of doing this in Android? I've read AsyncTask reference and it seems method onProgressUpdate() is only useful when using

What will happen if I use try catch and finally for handler using runnable?

大憨熊 提交于 2019-12-21 23:33:55
问题 I use the code below for getting some work done everytime after some time interval, and using post delay in 'finally' clause and oustide of runnable. Here is the code. Runnable runnable = new Runnable() { @Override public void run() { try { // do somthing } catch (Exception e) { // TODO: handle exception } finally { handler.postDelayed(this, 60000); } } }; handler.postDelayed(runnable, 60000); handler.postDelayed(runnable, 60000); will run two times or a single time. 回答1: it depends! first

Creating a notification for MediaPlayer with an Android Foreground Service

你说的曾经没有我的故事 提交于 2019-12-21 20:17:25
问题 Here is the problem. I am currently working on an application that must provide : A Radio Player (AAC live streaming from an url) And a PodCast player (MP3 Streaming from an url) The application must be able to run in background (Android Service) and be exposed to the user with a persistant notification in the Notification Bar (Android Foreground Service) (ONE problem per question so here i'll be asking for the notification) Since i have several class for managing players, i though creating a

Creating a notification for MediaPlayer with an Android Foreground Service

廉价感情. 提交于 2019-12-21 20:16:15
问题 Here is the problem. I am currently working on an application that must provide : A Radio Player (AAC live streaming from an url) And a PodCast player (MP3 Streaming from an url) The application must be able to run in background (Android Service) and be exposed to the user with a persistant notification in the Notification Bar (Android Foreground Service) (ONE problem per question so here i'll be asking for the notification) Since i have several class for managing players, i though creating a

Can't receive LocationClient's location updates after screen gone off

自古美人都是妖i 提交于 2019-12-21 17:27:44
问题 I'm trying to write a simple Android Service that runs in background and receives location updates from LocationClient (Google Map API Android V2). The problem is that when the screen go off, my Service doesn't receives anymore location updates. I tried to check if the service was active, even with screen off, and it does (I have a TimerTask scheduling a log). When screen is on I can receive location updates, but when screen goes off I see only TimerTask's logs and I don't receive any

HDMI out programming for dual screen

一个人想着一个人 提交于 2019-12-21 15:24:12
问题 In my search I found that, the Android SDK provides no support for controlling HDMI port activities and handling HDMI output, as of now. Though certain device manufacturers like Motorola (don't know if any other does that too) provide API's for a little better control. Below are the links to two of them, out of which the dual screen one (which suits my requirement pretty close) is deprecated. motorola hdmi status api motorola hdmi dual screen api Mirroring is the default behavior on

Can started and bound services live “forever”?

守給你的承諾、 提交于 2019-12-21 12:14:17
问题 I understand that a service can run in two modes, started and bound. What I don't quite understand from the developer docs or other questions on this site, is whether a service running as both started and bound will exit when the last component unbinds from it? 回答1: whether a service running as both started and bound will exit when the last component unbinds from it? If something called startService() on the Service , it will remain running, regardless of what bindService() and unbindService(

Long running service consumes a lot of battery

China☆狼群 提交于 2019-12-21 11:14:06
问题 I developed an app and some people complains that it takes too much battery, it is the second most consuming process after the screen. However, in some devices it does not consumes that much battery. All the work my app do is in a service. The service is sticky and is running all the time (the android system may kill it when has low resources or pause it when device go to sleep), it has listener to the accelerometer as long as the screen is on, it is not foreground service and does not hold

Long running service consumes a lot of battery

♀尐吖头ヾ 提交于 2019-12-21 11:14:01
问题 I developed an app and some people complains that it takes too much battery, it is the second most consuming process after the screen. However, in some devices it does not consumes that much battery. All the work my app do is in a service. The service is sticky and is running all the time (the android system may kill it when has low resources or pause it when device go to sleep), it has listener to the accelerometer as long as the screen is on, it is not foreground service and does not hold