Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onPause() {
- super.onPause();
- this.unregisterReceiver(allCustomerReceiver);
- this.unregisterReceiver(myCustomerReceiver);
- }
- @Override
- public void onResume() {
- super.onResume();
- this.registerReceiver(allCustomerReceiver, new IntentFilter(CustomerIntentService.CUSTOMER_INTENT_PUBLISH_ALL));
- this.registerReceiver(myCustomerReceiver, new IntentFilter(CustomerIntentService.CUSTOMER_INTENT_PUBLISH_MY));
- }
- private void startGetAllCustomersService() {
- Intent intent = new Intent(getApplicationContext(), CustomerIntentService.class);
- intent.setAction(CustomerIntentService.GET_ALL_CUSTOMERS_ACTION);
- startService(intent);
- }
- private void startGetMyCustomersService(String accountName, boolean isLogin) {
- Intent intent = new Intent(getApplicationContext(), CustomerIntentService.class);
- intent.setAction(CustomerIntentService.GET_MY_CUSTOMERS_ACTION);
- intent.putExtra("Account", accountName);
- intent.putExtra(CustomerIntentService.IS_LOGIN_PARAM, isLogin);
- startService(intent);
- }
- public BroadcastReceiver allCustomerReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if(intent != null) {
- // bla
- }
- }
- };
- public BroadcastReceiver myCustomerReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if(intent != null && intent.getExtras() != null) {
- //bla
- }
- }
- };
- ==========================================================================
- Service-ul de unde fac broadcast
- private void publishAllCustomers(String jsonResponse){
- Intent intent = new Intent(CUSTOMER_INTENT_PUBLISH_ALL);
- intent.putExtra(ALL_CUSTOMERS, jsonResponse);
- sendBroadcast(intent);
- }
- private void publishMyCustomers(String jsonResponse, boolean isLogin) {
- Intent intent = new Intent(CUSTOMER_INTENT_PUBLISH_MY);
- intent.putExtra(ALL_CUSTOMERS, jsonResponse);
- intent.putExtra(IS_LOGIN_PARAM, isLogin);
- sendBroadcast(intent);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement