Skip to content

Instantly share code, notes, and snippets.

@luizmarcus
Created February 22, 2016 23:37
Show Gist options
  • Save luizmarcus/dd3e41e3ad540b8d527a to your computer and use it in GitHub Desktop.
Save luizmarcus/dd3e41e3ad540b8d527a to your computer and use it in GitHub Desktop.
public class EventoReceiver extends BroadcastReceiver {
private EventBus bus = EventBus.getDefault();
@Override
public void onReceive(Context context, Intent intent) {
Evento evento = null;
if(intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)){
evento=new Evento("Carregando!");
} else if(intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED)){
evento=new Evento("Não está carregando!");
}
// Enviar o evento
bus.post(evento);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment