android-service

Creating a Service in Android

微笑、不失礼 提交于 2019-12-18 04:04:17
问题 I'm creating my first android app and I need to use a service. The UI will have a checkbox (CheckBoxPreference) that will be used to turn the service on/off and the service will only be accessed by my app (there's no need to share it). So far the UI for this functionality is ready and I know how to respond to the event, what I dunno is how to create a service nor how to connect to it whatsoever. The idea is that the service continues to listen for events and responding to them on the

Creating a Service in Android

半世苍凉 提交于 2019-12-18 04:04:07
问题 I'm creating my first android app and I need to use a service. The UI will have a checkbox (CheckBoxPreference) that will be used to turn the service on/off and the service will only be accessed by my app (there's no need to share it). So far the UI for this functionality is ready and I know how to respond to the event, what I dunno is how to create a service nor how to connect to it whatsoever. The idea is that the service continues to listen for events and responding to them on the

Service Automatic Called on Destroying Activity

风格不统一 提交于 2019-12-18 03:59:11
问题 I am stuck with the problem of Activity + Service in that I have following number of Activities and Services. Activities: LoginActivity => OrderListActivity => AddOrderActivity => ConfirmOrderActivity Services: ReceivingOrderService - Receiving New Data From Server SendingOrderService - Sending new Data to Server Above both Service Calling from another Separate Service on duration of some interval . CheckAutoSyncReceivingOrder - To call ReceivingOrderService (Interval 15Mins)

How to stop running services?

*爱你&永不变心* 提交于 2019-12-18 02:03:51
问题 I have this code that describes a service: public class navigation_web extends Service { Context context; public void navigation() { Cursor mCur = getContentResolver().query(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, null, null, null); mCur.moveToFirst(); if (mCur.moveToFirst() && mCur.getCount() > 0) { while (mCur.isAfterLast() == false) { Log.v("titleIdx", mCur.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX)); Log.v("urlIdx", mCur.getString(Browser.HISTORY_PROJECTION_URL_INDEX));

Can you start an IntentService on a separate process?

纵然是瞬间 提交于 2019-12-18 01:44:30
问题 Is it possible to start an IntentService on a separate process? How? If so, is it mandatory to bind to it? Is it possible to start an IntentService on a separate process AND run it in the foreground? What's the difference between android:isolatedProcess and android:process ? See: http://developer.android.com/guide/topics/manifest/service-element.html 回答1: 1) Is it possible to start an IntentService on a separate process? How? If so, is it mandatory to bind to it? Yes, you can start an

Android - Using Google Analytics v4 Campaign Measurement

左心房为你撑大大i 提交于 2019-12-18 01:15:30
问题 I have implemented Google Analytics Campaign Measurement according to this guide. Then I want to test if everything works good by following this guide. I have added these on AndroidManifest.xml : <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.gms.analytics.globalConfigResource" android:resource="@xml/global_tracker" /> <!-- Used for Google Play Store Campaign Measurement-->; <service

Service stop's whenever app is killed

我的未来我决定 提交于 2019-12-17 20:36:12
问题 START_STICKY don't work in my device whenever i kill my app then service don't start again, My device name is Redmi Note 3 Pro, but whenever i run same app in android emulator, it restarts the service when i kill the app and service don't stops until i stop it by stopService() method please help me out Problem Solved Done this: setting >Permissions>Autostart then turned on the Switch of my app , and Done! I got solution in this link: Solution Link 回答1: You need to add "android:process=:any

Android Service can be bind without start?

拜拜、爱过 提交于 2019-12-17 19:52:04
问题 In many articles, tutorials, docs, have read so far, that we call startService() or bindService(), both starts the service. We can call both also, but that's a different story. I am unable to bindService without startService(). private void bindTunManagerService(int flags) { TunnelManagerService.setParentActivity(this); Intent bindIntent = new Intent(this, TunnelManagerService.class); startService(bindIntent); tunManagerServiceStarted = bindService(bindIntent, tunConnection, BIND_AUTO_CREATE)

Observe LiveData from foreground service

落花浮王杯 提交于 2019-12-17 18:55:32
问题 I have a repository which holds the LiveData object and is used by both activity and a foreground service through a ViewModel. When I start observing from the activity everything works as expected. However observing from the service doesn't trigger the Observe. This is the code I use class MyService: LifecycleService() { lateinit var viewModel: PlayerServiceViewModel override fun onCreate() { viewModel = MyViewModel(applicationContext as Application) } override fun onStartCommand(intent:

What are the Advantages and Disadvantages of running a service in different process?

不打扰是莪最后的温柔 提交于 2019-12-17 18:43:29
问题 I want to run a long running Service in the background in my App.so i am using Service for that but in the service there is tag called android:process So my service is like.. <service android:name="com.purpleshade.services.ApplicationService" android:process=":myprocess"> Question:: So i want to know about the Advantages and disadvantages of running a Service in different Process. 回答1: Off the top of my head... Downsides: You have to use interprocess communication to talk to it, which is