Reputation: 445
When Android device boot up, my application will start working in the foreground. User can put my application to background and he\she can use other applications for a desired long time.
When user stop interaction with phone for 30 seconds or lock the phone, my application will (if required)unlock the phone and continue to become active in the foreground.
How can achieve this?
Upvotes: 0
Views: 169
Reputation: 24907
User can put my application to background and he\she can use other applications for a desired long time.
Starting from Android O you won't be able to reliably make your app work in background. System applies several restrictions on background processing especially running background services. Only alternative would be to create Foreground Service. But if OS detects that you are performing CPU intensive work this won't work either.
When user stop interaction with phone for 30 seconds or lock the phone, my application will (if required)unlock the phone and continue to become active in the foreground.
Unfortunately its not possible. Even if manage to get Administrator rights there is no API which allows developers to unlock the phone without user's action. This would be a privacy breach.
Upvotes: 1