Created
February 25, 2017 20:52
-
-
Save parahall/fba35b45f3d23261824c1e51f105deb3 to your computer and use it in GitHub Desktop.
BackgroundService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BackgroundService extends Service { | |
@Override public int onStartCommand(Intent intent, int i, int i1) { | |
if (observer == null) { | |
observer = new OrdersObserver(new Handler()); | |
getContext().getContentResolver() | |
.registerContentObserver(KolGeneContract.OrderEntry.CONTENT_URI, true, observer); | |
} | |
} | |
//... | |
@Override public void handleMessage(Message msg) { | |
super.handleMessage(msg); | |
Order order = (Order) msg.obj; | |
Intent intent = new Intent(context, SendOrderService.class); | |
intent.putExtra(SendOrderService.ORDER_ID, order.getLocalId()); | |
context.startService(intent); | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment