EnoughPhoneIsEnough
On average, the typical person opens up their phone 150 times per day, and this number can easily increase to 300, this means once every 5 minutes.
Cannot force yourself to use your phone less?
Maybe if money is involved in this equation you are going to be more motivated. Every time you open up the phone you are going to voluntarily pay 0.003$, not much, but in time it gathers.
Also, 50% of the money you are paying will go towards solving an environmental problem, itβs a win-win.
How does it work
In order to track the amount of phone pickups, a foreground service is continuously running and listening to broadcasts of type Intent.ACTION_SCREEN_ON. I have used a foreground service because itβs intended to do a task that the user must be aware of (by always displaying a notification like the one below). Also, this kind of service has significantly lower chances of being shut down by the system.
Although sometimes my service was stopping and in order to tackle this, I have set up a PeriodicWorkRequest that opens the foreground service if it is not running. The new API is quite straightforward to use.
val work = PeriodicWorkRequest.Builder(StartScreenOnWorker::class.java, 16, TimeUnit.MINUTES).build()
WorkManager.getInstance().enqueueUniquePeriodicWork("EnoughIsEnough", ExistingPeriodicWorkPolicy.KEEP , work);
The timestamp (in seconds) of each new pickup is persisted in a local SQLite database that is queried later to populate the graphs with the needed data.
var pRepository = PickUpsRepository.getInstance(context)
pRepository.insertPickUp(pickup = Pickup(timeStamp))
Validation
As I wanted first to validate my idea, there is no code written that actually processes payments, but at the first start of the application, I do query the user to see their intentions.
TECHNOLOGIES USED
Mobile:
- Kotlin
- SQLite
- https://github.com/PhilJay/MPAndroidChart
GITHUB
This Markdown version captures images, videos, links, and text content while maintaining the structure of the original HTML content. Adjust image and video paths as needed to fit your actual URL setup.