1

How to detect user activity/inactivity in android service/background application - from same or other applications?

I want to know that user stop touching screen and not busy with another activity to show notifiation popup. Not sure is there no other method than use AccessibilityService.

Szymon
  • 42,577
  • 16
  • 96
  • 114
Chameleon
  • 9,722
  • 16
  • 65
  • 127

3 Answers3

1

One of the ways is to know that from reading the Android logs

Siki
  • 111
  • 4
0

Define a interface in activity and service. in oncreate of activity set reference to activity in service method. Now you have activity reference for entire service lifetime.

another way to do this is, application class, same application class is shared by activity and service, so you can both of these from each other using application class.

If you want see from applications then use broadcastreceivers that is the only wau

Amrut
  • 543
  • 4
  • 8
0

Use a boot receiver to setup the AlarmManager (and of course also check to start the polling from your main Activity too, for the case when your app is installed and the system is not booted) and have the AlarmManager send an Intent for another receiver.

I think they answered it in this question to do what you are looking for: android: running a background task using AlarmManager

Community
  • 1
  • 1
apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69