I have a service in which the OS kills - the problem is that when it kills it and plans to restart it, it is planned to restart it in an hour. This service supports two receivers for changing the Bluetooth connection, so I need to restart much faster, instead of sitting in the "Restart" state for more than an hour.
Here is a magazine clipping:
I/ActivityManager( 1064): No longer want com.deadbeat.bta (pid 25455): hidden
After this 3600 seconds, he simply kills him and transfers it again 2 hours later and so on. When this happens, it seems that onDestroy (), onCreate () and onStartCommand () are not being called. Starting the main action will successfully restart the service, and everything will be fine for several hours until it starts again.
It started when I made a change that requires me to go through additional functions when the service is running.
Here is my onStartCommand and onCreate if this helps ...
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d("BTA", ">>> onStartCommand()"); setIntent(intent); Bundle extras = getIntent().getExtras(); if (extras != null) { setGlobals((Globals) extras.getSerializable("Globals")); } if (getGlobals() == null) { Log.e("BTA", "!!! Call an ambulance!!"); } Log.i(getGlobals().getLogPrefix(), ">>> Service starting up"); setWorker(new BTAWorker(this, getGlobals())); getWorker().doLog("Service Worker Set and Active"); return START_REDELIVER_INTENT; } @Override public void onCreate() { // Create super.onCreate(); Log.d("BTA", ">>> onCreate()"); // Register BroadcastReceiver with connect and disconnect actions IntentFilter intentToReceiveFilter = new IntentFilter(); intentToReceiveFilter.addAction("android.bluetooth.device.action.ACL_CONNECTED"); intentToReceiveFilter.addAction("android.bluetooth.device.action.ACL_DISCONNECTED"); registerReceiver(this.mIntentReceiver, intentToReceiveFilter, null, this.mHandler); Log.d("BTA", ">>> Bluetooth State Receiver registered"); Log.d("BTA", ">>> Intent = " + getIntent()); }
Any advice regarding what I am doing wrong will be greatly appreciated. I searched, but did not find anything like this long delay on restart. Should parent activity for START_REDELIVER_INTENT work? (Therefore, when my main action is cleared, I can no longer restart the service without reopening the main action?) Or is something else happening?