android-service

IntentService connected to Server listening

本小妞迷上赌 提交于 2019-12-08 03:58:25
I coded an IntentService where I send a command line. Is related to an activity where I'm trying to program a Console. The activity's purpose is to do a 'command prompt' where I can send and receive to/from the server. The Service's action is: COnnect to the server Send command line Get response Retrieve response to user The main problem is that every time I send a command line, the Service has to reconnect to the server. (Cause every time I'm starting the whole Service) How can I avoid this step? I would like to "keep alive" the service waiting for a command line to send, without the need of

IBinder casting *sometimes* results in ClassCastException when binding to service

狂风中的少年 提交于 2019-12-08 03:47:33
问题 We bind to our local service (same process) in Application subclass but sometimes we are getting a ClassCastException. I have no idea how to fix it since everyone says the exception occurs if the service process is different than your application. How can this be fixed? Application subclass: public class App extends Application implements ServiceConnection { private ServiceApi exposedServiceApi; private EventBus eventBus; @Override public void onCreate() { super.onCreate(); bindToService(); }

Call service method from notification with BroadcastReceiver in Xamarin Android

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 03:30:48
问题 I start a service and create new thread (downloading a large file). At the same time I display a notification with action (pause button). When I press this button "WSTRZYMAJ" I want call PauseDownload() method from my service. How can I do this? I have read about BroadcastReceiver, create this class but how to call method from service from BroadcastReceiver class? Screen from notification: Fragment of my service: class DownloadsService : Service { DownloadsBroadcastReceiver receiver;

Using Intents as a form of message passing

混江龙づ霸主 提交于 2019-12-08 03:21:28
Are there any drawbacks to using intents as a form of message passing between two apps that I control? I have two apks which will always exist on the device together. And, I'd like to use explicit intents to pass messages back and forth as opposed to creating and managing two separate services. Using explicit intents just seems like an easier to manage approach than services. Communication between applications can expose certain rich, but if you really need to do this way, you can only customizing permissions that your applications will have knowledge. Then you can use BroadcasrReceiver to

How to check inside service is same service already running?

时光毁灭记忆、已成空白 提交于 2019-12-08 01:50:39
问题 I have a service which is used by many application. Developers just start the service and it does its work. If AppA, AppB and AppC start the service I am getting duplicates of my services. Duplicates are not so bad, in fact there should be duplicates of service, but services should do their work if and only if none of duplicates are already doing same job. My problem is, checking inside service wether its runing looks like against logic because if you start service, of course its already

How to configure Android AccessibilityService

喜欢而已 提交于 2019-12-08 01:40:49
问题 I am investigating Android AccessibilityService and wanted to see all possible types of events, gestures and Key Events. I am able to receive all public void onAccessibilityEvent(final AccessibilityEvent accessibilityEvent) {} however my service nevers receives protected boolean onGesture(int gestureId) {} or protected boolean onKeyEvent(KeyEvent event) {} calls. When I enable my accessibility service in the accessibility settings I see the service connect OK and I can see the service logging

Pending Intent created in Native Extension works only from Notification but not within Service

独自空忆成欢 提交于 2019-12-08 00:52:14
问题 I’m developing an Air mobile application for Android which uses Air Native Extensions (ANE). From the ANE I call a function that creates a Pending Intent which is passed to a Notification. Next, the native function starts a service and passes it the Pending Intent and the Notification. Here’s the code for that part: public class StartServiceFunction implements FREFunction { @Override public FREObject call(FREContext context, FREObject[] args) { Log.d("MyApplicationStartServiceFunction", "call

Binding and starting a service when application starts

主宰稳场 提交于 2019-12-07 23:57:30
I have a service in Android that encapsulates a framework that has a start method. The service boils down to something like this, many things omitted: public class MyService extends Service { private IBinder thisBinder; public MyService(){ thisBinder = new LocalBinder(); } @Override public IBinder onBind(Intent intent) { return thisBinder; } public void start(Map<String, Object> options) { getDriverManager().start(options); } } I also have a bridging class that makes calls to the service: public class MyServiceBridge implements ServiceConnection { private boolean started = false; private

Service and IntentService, Which is better to run a service that poll database value from the server?

放肆的年华 提交于 2019-12-07 23:50:56
问题 I had read quite a number of resources regarding the Service and IntentService . However when come to make a decision, I am not confident enough to choose which type to use in order to create a background service that will poll data from database in a time interval and stop it when I get the data I want since the data represent a status of a request, eg. ordering medicine confirmation status(pending, completed, in progress). I need to detect when a status is set to "completed" and send a

Is it possible to use AWS Android TransferUtility in Service?

こ雲淡風輕ζ 提交于 2019-12-07 21:01:44
问题 The AWS Android SDK for S3 includes classes for data transfers. Namely, the TransferUtility . The TransferUtility seems to create a service for its own use. Is it possible to use it from a service and in particular set the transfer listener and use it to send updates to application or create notifications from within said service? 回答1: Yes it's possible to start a service from another service. TransferUtility may fail to work if its Amazon S3 client gets garbage collected before