android-service-binding

How to access instance of MediaBrowserServiceCompat service?

时光毁灭记忆、已成空白 提交于 2019-12-04 19:35:33
I'm surprisingly struggling to get hold of the instance of a service which is derived from MediaBrowserServiceCompat . For a typical service, to achieve that, a local binder is used class MyService extends MediaBrowserServiceCompat { class MyBinder extends Binder { public MyService getService() { return MyService.this; } private final MyBinder binder = new MyBinder(); @Override public IBinder onBind(Intent intent) { return binder; } public void doMagic() { // <-- How to call this from activity? // ... } } // At the activity, for example, this binder is retrieved through // `onServiceConnected(

Issue Moving from IntentService to JobIntentService for Android O

荒凉一梦 提交于 2019-12-04 12:44:28
I am using Intent Service to monitor Geofence transition. For that I am using following call from a Sticky Service. LocationServices.GeofencingApi.addGeofences( mGoogleApiClient, getGeofencingRequest(), getGeofencePendingIntent() ) and the Pending Intent calls Transition service (an IntentService) like below. private PendingIntent getGeofencePendingIntent() { Intent intent = new Intent(this, GeofenceTransitionsIntentService.class); // We use FLAG_UPDATE_CURRENT so that we get the //same pending intent back when calling addgeoFences() return PendingIntent.getService(this, 0, intent,

Bind to service from new Context for configuration changes or bind from app context?

不想你离开。 提交于 2019-12-02 19:37:24
I'm trying to work out if bound service is appropriate for doing background work in my app. The requirements are that various application components can make web requests through it of varying priority. (Thus the service must maintain some sort of queue and be able to cancel it's ongoing requests for others of higher priority). I'd like the service to be relatively unobtrusive to the user such that they don't find it running after they are done with the application - if I want to do something more important that continues while the application is closed I can use startForeground() to push a

how to make sure service is not killed

人盡茶涼 提交于 2019-12-02 11:54:41
问题 I am trying to write a music player in Android, and was trying to use service to play music in infinite loop in background. And I need the service to interact with the activity for volume control and so on. The question is, if I use service binder then the service will likely to be terminated with the activity when the activity is in the background. How to make sure the service can keep running without the activity and in activity some of the service's method can still be called? Is using

how to make sure service is not killed

妖精的绣舞 提交于 2019-12-02 05:23:12
I am trying to write a music player in Android, and was trying to use service to play music in infinite loop in background. And I need the service to interact with the activity for volume control and so on. The question is, if I use service binder then the service will likely to be terminated with the activity when the activity is in the background. How to make sure the service can keep running without the activity and in activity some of the service's method can still be called? Is using foreground service with binder a solution? The service will not be killed in this way? Thanks in advance!

Doubts about bindService

只谈情不闲聊 提交于 2019-12-02 01:28:54
问题 I have some boubts about Android bound service. The guide: http://developer.android.com/guide/components/bound-services.html ,about bindService() , says: The `bindService()` method returns immediately without a value But this does not seems to be correct, since here the signature of the method is public abstract boolean bindService (Intent service, ServiceConnection conn, int flags) where the returned boolean value is described as below: If you have successfully bound to the service, true is

Doubts about bindService

人盡茶涼 提交于 2019-12-01 20:33:40
I have some boubts about Android bound service. The guide: http://developer.android.com/guide/components/bound-services.html ,about bindService() , says: The `bindService()` method returns immediately without a value But this does not seems to be correct, since here the signature of the method is public abstract boolean bindService (Intent service, ServiceConnection conn, int flags) where the returned boolean value is described as below: If you have successfully bound to the service, true is returned; false is returned if the connection is not made so you will not receive the service object.

Android download queue using DownloadManger

倾然丶 夕夏残阳落幕 提交于 2019-11-30 23:17:55
I'm using DownloadManager to download my files in android and its great since it handles everything (connectivity lost, retry, etc.) The problem is I want my file to be downloaded in queue one after another and as far as i know DownloadManager doesn't provide this functionality. So multiple call to DownloadManager.enqueue(...) results in concurrent download of all the files. How can i fix this? I can not just make a queue in my activity and send downloads to DownloadManger one by one since activity may be destroyed at any time! Also IntentService doesn't work here!! even though it handles

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

南笙酒味 提交于 2019-11-30 07:34:32
问题 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

Android java.lang.IllegalArgumentException: Service not registered

自古美人都是妖i 提交于 2019-11-30 01:19:39
I have a setup that looks something like this: class MyFragment implements SomeEventListener { Application mAppContext; boolean mBound; boolean mDidCallUnbind; MyIBinder mBinder; ServiceConnection mConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { mBound = true; mBinder = (MyIBinder) service; mBinder.getThings();... } @Override public void onServiceDisconnected(ComponentName name) { mDidCallUnbind = false; mBound = false; mBinder = null; } }; ... @Override public void onSomeEvent() { mAppContext.bindService(...); } void