Code Monkey home page Code Monkey logo

Comments (6)

opcitsistemas avatar opcitsistemas commented on June 25, 2024

Same issue, i notice that if i close the app the service stop logging, in the running apps in the device i see the app but with 0 process and 1 service

Phonegap 4.2.0-0.23.0
Android Device 4.4.2

from bgs-core.

Red-Folder avatar Red-Folder commented on June 25, 2024

Does the service ever start?

The service should show in logcat as "MyService". I'm not seeing it in the above logcat - this maybe because the service hasn't started or you've filtered out of the logcat.

If in doubt, post a full logcat of start, run, stop (full lifecycle)

from bgs-core.

aravintha avatar aravintha commented on June 25, 2024

Service is started ..timer task run every time interval when the app is open....if i close the app then timer task never run(for checking used the notificaton in doWork()) ....the above one is the stacktrace in my app..if you want i will send my entire application..

from bgs-core.

Red-Folder avatar Red-Folder commented on June 25, 2024

In your logcat, you should have various logs Tag'ed as "Background Service"

You should see the Background Service giving messages like "Timer task starting work" & "Timer task completing work". This the code that wraps the doWork.

Are you seeing these message in your logcat when the app is open? Are you seeing these message in your logcat when the app is closed?

(If in doubt, post the whole logcat)

from bgs-core.

aravintha avatar aravintha commented on June 25, 2024

Logcat(When starting the service)

D/BackgroundServicePluginLogic(16652): Start of Execute
D/BackgroundServicePluginLogic(16652): Withing try block
D/BackgroundServicePluginLogic(16652): Finding servicename com.processdrive.novema.NovemaStagingBackupService
D/BackgroundServicePluginLogic(16652): Services contain 0 records
D/BackgroundServicePluginLogic(16652): Creating new Service Details
D/BackgroundServicePluginLogic(16652): Action = getStatus
D/BackgroundServicePlugin(16652): logicResult = com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ExecuteResult@41e66c40
D/BackgroundServicePlugin(16652): Start of transformResult
D/BackgroundServicePlugin(16652): Status is OK
D/BackgroundServicePlugin(16652): We have data
D/BackgroundServicePlugin(16652): End of transformResult
D/BackgroundServicePlugin(16652): pluginResult = org.apache.cordova.PluginResult@41e6f378
D/BackgroundServicePlugin(16652): pluginResult.getMessage() = {"ErrorCode":0,"Success":true,"RegisteredForUpdates":false,"RegisteredForBootStart":false,"ErrorMessage":"","ServiceRunning":false}
D/BackgroundServicePlugin(16652): Dont keep Callback
D/BackgroundServicePluginLogic(16652): Start of Execute
D/BackgroundServicePluginLogic(16652): Withing try block
D/BackgroundServicePluginLogic(16652): Finding servicename com.processdrive.novema.NovemaStagingBackupService
D/BackgroundServicePluginLogic(16652): Services contain 1 records
D/BackgroundServicePluginLogic(16652): Found existing Service Details
D/BackgroundServicePluginLogic(16652): Action = startService
D/ServiceDetails(16652): Starting startService
D/ServiceDetails(16652): Attempting to bind to Service
D/ServiceDetails(16652): Starting bindToService
D/ServiceDetails(16652): Attempting to start service
W/ContextImpl(16652): Implicit intents with startService are not safe: Intent { act=com.processdrive.novema.NovemaStagingBackupService } android.content.ContextWrapper.startService:494 com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ServiceDetails.bindToService:604 com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ServiceDetails.startService:335
D/ServiceDetails(16652): Attempting to bind to service
W/ContextImpl(16652): Implicit intents with startService are not safe: Intent { act=com.processdrive.novema.NovemaStagingBackupService } android.content.ContextWrapper.bindService:517 com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ServiceDetails.bindToService:607 com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ServiceDetails.startService:335
D/ServiceDetails(16652): Waiting for service connected lock
I/BackgroundService(16652): Service creating
I/BackgroundService(16652): Initialising the service
I/BackgroundService(16652): Syncing result
I/BackgroundService(16652): Service started
I/BackgroundService(16652): onBind called
D/BackgroundService(16652): Listener added
D/ServiceDetails(16652): Finished bindToService
D/ServiceDetails(16652): Bind worked
D/ServiceDetails(16652): Finished startService
D/BackgroundServicePlugin(16652): logicResult = com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ExecuteResult@41e58488
D/BackgroundServicePlugin(16652): Start of transformResult
D/BackgroundServicePlugin(16652): Status is OK
D/BackgroundServicePlugin(16652): We have data
D/BackgroundServicePlugin(16652): End of transformResult
D/BackgroundServicePlugin(16652): pluginResult = org.apache.cordova.PluginResult@41e74750
D/BackgroundServicePlugin(16652): pluginResult.getMessage() = {"TimerMilliseconds":60000,"LatestResult":{},"ErrorMessage":"","Configuration":{},"ErrorCode":0,"Success":true,"RegisteredForUpdates":false,"RegisteredForBootStart":false,"TimerEnabled":true,"ServiceRunning":true}
D/BackgroundServicePlugin(16652): Dont keep Callback
D/CordovaActivity(16652): onMessage(spinner,stop)
D/BackgroundServicePluginLogic(16652): Start of Execute
D/BackgroundServicePluginLogic(16652): Withing try block
D/BackgroundServicePluginLogic(16652): Finding servicename com.processdrive.novema.NovemaStagingBackupService
D/BackgroundServicePluginLogic(16652): Services contain 1 records
D/BackgroundServicePluginLogic(16652): Found existing Service Details
D/BackgroundServicePluginLogic(16652): Action = registerForUpdates
D/BackgroundServicePlugin(16652): logicResult = com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ExecuteResult@41e76008
D/BackgroundServicePlugin(16652): Start of transformResult
D/BackgroundServicePlugin(16652): Status is OK
D/BackgroundServicePlugin(16652): We have data
D/BackgroundServicePlugin(16652): Keep Callback set to true
D/BackgroundServicePlugin(16652): End of transformResult
D/BackgroundServicePlugin(16652): pluginResult = org.apache.cordova.PluginResult@41e7c500
D/BackgroundServicePlugin(16652): pluginResult.getMessage() = {"TimerMilliseconds":60000,"LatestResult":{},"ErrorMessage":"","Configuration":{},"ErrorCode":0,"Success":true,"RegisteredForUpdates":true,"RegisteredForBootStart":false,"TimerEnabled":true,"ServiceRunning":true}
D/BackgroundServicePlugin(16652): Keep Callback
I/BackgroundService(16652): Timer task starting work
D/BackgroundService(16652): Is the service paused?
D/BackgroundService(16652): Service is not paused

I/BackgroundService(16652): Syncing result
I/BackgroundService(16652): Sending to all listeners
D/ServiceDetails(16652): Latest results received
D/ServiceDetails(16652): Calling listener
D/BackgroundServicePlugin(16652): Starting handleUpdate
D/BackgroundServicePlugin(16652): Sending update
D/BackgroundServicePlugin(16652): Start of transformResult
D/BackgroundServicePlugin(16652): Status is OK
D/BackgroundServicePlugin(16652): We have data
D/BackgroundServicePlugin(16652): Keep Callback set to true
D/BackgroundServicePlugin(16652): End of transformResult
D/BackgroundServicePlugin(16652): Sent update
D/BackgroundServicePlugin(16652): Finished handleUpdate
D/ServiceDetails(16652): Listener finished
I/BackgroundService(16652): Sent listener - 0
I/BackgroundService(16652): Timer task completing work

Timer task start work(when the app is open)

I/BackgroundService(16652): Timer task starting work
D/BackgroundService(16652): Is the service paused?
D/BackgroundService(16652): Service is not paused

I/BackgroundService(16652): Syncing result
I/BackgroundService(16652): Sending to all listeners
D/ServiceDetails(16652): Latest results received
D/ServiceDetails(16652): Calling listener
D/BackgroundServicePlugin(16652): Starting handleUpdate
D/BackgroundServicePlugin(16652): Sending update
D/BackgroundServicePlugin(16652): Start of transformResult
D/BackgroundServicePlugin(16652): Status is OK
D/BackgroundServicePlugin(16652): We have data
D/BackgroundServicePlugin(16652): Keep Callback set to true
D/BackgroundServicePlugin(16652): End of transformResult
D/BackgroundServicePlugin(16652): Sent update
D/BackgroundServicePlugin(16652): Finished handleUpdate
D/ServiceDetails(16652): Listener finished
I/BackgroundService(16652): Sent listener - 0
I/BackgroundService(16652): Timer task completing work

when close the app

D/BackgroundServicePluginLogic(16652): On Destroy Start
D/BackgroundServicePluginLogic(16652): Checking for services
D/BackgroundServicePluginLogic(16652): Found services
D/BackgroundServicePluginLogic(16652): Calling service.close()
D/ServiceDetails(16652): Close called
D/ServiceDetails(16652): Listener deregistering
D/ServiceDetails(16652): Listener closing
D/BackgroundServicePlugin(16652): Starting closeListener
D/BackgroundServicePlugin(16652): Sending update
D/BackgroundServicePlugin(16652): Start of transformResult
D/BackgroundServicePlugin(16652): Status is OK
D/BackgroundServicePlugin(16652): We have data
D/BackgroundServicePlugin(16652): End of transformResult
D/BackgroundServicePlugin(16652): Sent update
D/BackgroundServicePlugin(16652): Finished closeListener
D/ServiceDetails(16652): Listener closed
D/ServiceDetails(16652): Listener deregistered
D/ServiceDetails(16652): Removing ServiceListener
D/BackgroundService(16652): Listener removed
D/ServiceDetails(16652): Removing ServiceConnection
D/ServiceDetails(16652): Close finished
D/BackgroundServicePluginLogic(16652): On Destroy Finish

from bgs-core.

aravintha avatar aravintha commented on June 25, 2024

The following code resolved the issue...Your plugin works well the problem is android kitkat version..

Thank you so much...

http://stackoverflow.com/questions/20673403/android-services-start-sticky-does-not-work-on-kitkat?lq=1

// this is for kitkat (nexus 7 tablet) service issue
public void onTaskRemoved(Intent rootIntent) {
// TODO Auto-generated method stub
Intent restartService = new Intent(getApplicationContext(),
this.getClass());
restartService.setPackage(getPackageName());
PendingIntent restartServicePI = PendingIntent.getService(
getApplicationContext(), 1, restartService,
PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmService = (AlarmManager)getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() +1000, restartServicePI);
}
the code is place in BackService.java class..

from bgs-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.