android-service

WakefulIntentService implementation clarifications

人走茶凉 提交于 2019-11-29 11:11:01
Commonsware's WakefulIntentService works beautifully but there are some things I do not quite get. Below is the core of the service - a stripped down version of the source : class WIS extends IntentService { private static final String NAME = WIS.class.getName() + ".Lock"; private static volatile WakeLock lockStatic = null; synchronized private static PowerManager.WakeLock getLock(Context context) { if (lockStatic == null) { PowerManager mgr = (PowerManager) context .getSystemService(Context.POWER_SERVICE); lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, NAME); lockStatic

Firebase push notification issue in Android when app is closed/killed

萝らか妹 提交于 2019-11-29 11:08:23
Firebase push does not work on some devices when app is closed with only data payload. See this thread: https://github.com/firebase/quickstart-android/issues/41 I know when app is killed by swipe then some OEM kill all the services of the app which directly effect FirebbaseMessagingService and due to this onMessageReceived() method never invoked. I have also tried with high priority FCM but sadly no success. Here are the phones on which I am facing an issue: OnePlus, Lenovo, Huawei. Currently, I am testing with OnePlus 5, when I change the battery setting to "Don't Optimise" then push

Can I use Android Camera in service without preview?

拟墨画扇 提交于 2019-11-29 10:56:32
问题 I have create a application in Android that using a camera I can measure out the distance between user's face to the phone screen. Problem description: Now I want to make it running background so that the feature is available while I am using other applications. It means I should open camera in service without preview, and process it in service. What I did yet: I referred some questions here How to record video from background of application : Android How to use Android Camera in Background?

android service notify activity completed best way?

做~自己de王妃 提交于 2019-11-29 09:08:41
问题 I created a service which syncs data from the web on a background thread and want to notify a list activity when the service has completed so it can update it's cursor? What would be the best way to do this? I'm thinking of sending a broadcast when the service is done but not sure if that's the best way to do it. I need to requery the cursor when the service has finished so I'm not sure if that will work well with broadcast receivers? I haven't done alot of android in awhile so thanks in

AIDL interface can't find import for Parcelable class

五迷三道 提交于 2019-11-29 09:01:20
My issue seems to be similar to this question and this one but it is a bit different. I am making an AIDL service that is in a Library project and using it in my application. I have a class Vehicle that is in my application that I have made parcelable so that I can use it in my interface. (I would like to get a List of vehicles from my service that is in the library to my application) Do I need a Vehicle.java in both the application and the library? Do I need a Vehicle.aidl in both? I had Vehicle.java AND Vehicle.aidl in both application and library and I began running into a problem in my

How do I detect skype/telegram/whatsapp calls when my messenger app is in a call or wants to make a call?

柔情痞子 提交于 2019-11-29 07:54:36
I am wondering if there is a way I can detect a skype call/telegram/whatsapp/fb messenger call etc in progress or incoming call etc just like the regular phone call with telephony manager/listener? I would like to have some kind of mechanism that detects an ongoing /incoming etc call from skype/telegram etc for my app. I came across this solution : Call Detection for skype in android but not sure if it'll work for all generic messenger apps. Is there a hack or any kind of listener I can implement on my side that allows me to detect these? Any ideas would be awesome. Thanks! You can use the

Situations when a Service's onDestroy() method doesn't get called?

会有一股神秘感。 提交于 2019-11-29 07:46:44
I'm aware that a Service's onDestroy() method may never be called but can someone tell me when such a scenario might occur? I'm especially interested in whether it's possible for a Service to be killed, yet its VM would continue to run. I ask because I have a service that registers ContentObservers in the service's onStartCommand() method and unregisters them onDestroy(). If the service's onDestroy() method was never called because the whole VM was killed (along with the observers it created,) that would be fine. But I'm wondering if it's possible for a service to "go away" without onDestroy()

Rapid IPC with Messengers or AIDL

半世苍凉 提交于 2019-11-29 07:23:18
I'm attempting to create a program in Android which communicates rapidly with a remote service (~40,000/sec), however all Android IPC seems to fall short of being able to accomplish this task. My first attempt involved a standard Messenger system which was unable to do more then ~2,000/second and equally bad was that it seemed punctuated with intermittent lag. MainActivity (Test with Messengers) public class MainActivity extends Activity implements ServiceConnection{ Messenger mServiceMessenger; Messenger mClientMessenger = new Messenger(new ClientHandler()); @Override protected void onCreate

How can Android service update the UI of the activity that started it?

允我心安 提交于 2019-11-29 06:44:37
问题 I'm new to Android programming, so I'm facing some general problems about choosing the best way to design my app. What I want to do is basically a media player. I want the media player to run on a service because I want it to play also when the activity is not displayed. My question is, how can I update the UI on my activity depending on the service working flow (for example, the song changes and I want its name to be displayed)? I guess I could use a Local Broadcast Manager in order to send

Android: Stop/start service created in onCreate()

安稳与你 提交于 2019-11-29 06:09:19
I currently have a service that is started within the onCreate method of an activity using: Intent intentService = new Intent(this, MainService.class); this.startService(intentService); I need to now be able to stop this service on a button press and restart it again on another button press, however I am unsure how to stop this service and start it again out side of the onCreate method. I guess I would need to start the service in a different way than what I am currently doing? But I am unsure on the best method for this. I had looks at stop service in android but their method of starting the