This repo contains implementation of various Broadcast Receiver(like Screen On/Off, Device lock/unlock, Headphone plugged in/out, Wifi enabled/disabled/connected/disconnected, Bluetooth enabled/disbaled/connected/disconnected and much more) in a very modular and simpler way.
To understand the code of each Broadcast Receiver or just simply Ctrl+c and Ctrl+v to use it in your project.
- Boot Completed
- Screen Off
- Screen On
- Device Unlocked
- Device locked
- Power Source is connected(Charging)
- Power Source is disconnected(Discharging)
- Batter Low
- Earphone plugged in/Out
- Internet is connected
- Bluetooth Turning On/Off
- Bluetooth On/Off
- Bluetooth Connected/Disconnected(Even shows the name of the device to which it is connected, or from disconnected)
- GPS is On
- GPS is off
- Wifi Enabled/Disbaled
- Wifi Connected/Disconnected
- Wifi Enabled but not connected
Neither any extra dependency nor any third party module is required.
All these above mentioned Broadcast Receivers gets triggered whenever those events happen, I have put Toast and Logcat messages when they get triggered but you can replace them with whatever you want to do, like changing wallpaper whenever your phone is charging, or like launching something when battery is low, or play some sound whenever bluetooth gets connected and much more. All these infinite possibilities are there, you can make whatever you want.
Here "Connected to parrot" is result of my phone's bluetooth connected to my laptop "parrot".
Here you can see Power Connected/Disconnected and Headphone Plug in/out broadcast receivers.
No bugs. However, as multiple Toast messages will overlap each other so, you might not see toast messages in proper order. But as code is completely valid and sequential, so you will get correct result in logcat. And if you replace these Toasts and logcat messages with your own action you will not face any problem. It's just Toasts aren't reliable when used in bulk.