Triển khai services trên android
Dự án retailsmarter sau này sẽ cần dùng đến để chạy ngầm và nạp dữ liệu cho widget sản phẩm hoặc top sản phẩm

Trần Phước Hùng Blog

To create a application to run in the background of other current activities, one needs to create a Service. The Service can run indefinitely (unbounded) or can run at the lifespan of the calling activity(bounded).
Please note that a Service has a different lifecycle than activities therefore have different methods. But to begin a service in the application a call to startService() which envokes the service onCreate() method and onStart() beginning running the service.
context.startService() | ->onCreate() – >onStartCommand() [service running]
Calling the applications stopService() method to stop the service.
context.stopService() | ->onDestroy() [service stops]
Something that we didn’t use in this example is bindService() which just calls the services onCreate() method but does not call the onStartCommand(). onBindService() is used to create persistance connection to the service.
context.onBindService() | ->onCreate() [service created]
This Services Demo is simple as it plays a audio file and by listening to click events…

View original post 362 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: