Android - Last screen lock time - android

Is there a way to find the last time or the time spent since the user locked/unlocked the screen? Is there any log which stores this information?
I am trying to track user (in)activity and looking for the simplest possible way to do it. I know it can be done by continuous tracking through a service perhaps, but was trying to avoid doing that.

It seems that this cannot be done.
I ended up creating a new service which track the last screen lock/unlock and save the time myself.

Related

android get actual time

I am designing an app. I am facing this one problem. I want to get time from the user's device even if the user has changed the time(which is not the exact correct time).
+
If the user changes the time or time-zone, somehow; the application should notify the app.
However, I need to check this offline. Please suggest me a suitable way to tackle this Candy crush-like scenario in my app.
Thanks in advance.
You can use the UTC time. System.currentTimeMillis() REF

Trace time spent on each app in Android?

Is it possible to run a background service in android which can store the time spent on any application in android and also if we can take timely screenshots with the use of that background service in android.
I mean here that we can know that user has spent this much amount of time on this app and also take screenshots after each 5-15 mins?
Is it possible?
Please suggest some solution here.
Edited
Ok Lets forget screenshots. How can we trace time spent on which application? Same as below app
https://play.google.com/store/apps/details?id=com.appuccino.frequencyfree
You can get running processes by calling.
ActivityManager.getRunningAppProcesses()
you can save an array or List and get the processes running in foreground one by one. Then for getting ElapsedTime you can call getElapsedCpuTime()

App Idle time in android appln

I have an android app am displaying web view in my app but my problem is to find out the idle time of my app because after session expires i want show the login screen how can i do programatically in android.
Thanks in advance
if i'm given that problem, i would say have a timer running, with an incrementing integer every like 1 minute. and if and interaction with the device simply resets it to zero. there maybe a better solution to that though, that's just my logic.

Android: real-time friend list update

I just made an app where a friend list is being updated in real time depending on if you get blocked or deleted by one of your friends, so I refresh the list on the screen. However, I was wondering what would be appropriate as the time interval for updates using threads? right now I am using 1 second but I think it's a bit exaggerated.
I would have it as user defined. If you set a default time that is unchangeable, some users may think it is running the thread too often. They may also think your app is causing bad battery life. Just have a few options like Twitter or Facebook. Something like 1,5,10,30,60,180,etc.

Time since the app is open in android

Hello
In my android application i would like to get Time since when the app is opened.
Initially what i tried was getting the time when the app is loaded from the server and then taking the difference with the current time from the device.But by doing that if the user changes the time then i willnot be getting the actual time.
Its not posiible to hit the server again for the same.
Is there any way to achieve this in android?
Please share your valuable suggestions.
Thanks in advance:)
Try the "SystemClock" class, "uptimeMillis()" method.
Store the result in a variable when the app starts.
Echoing what I said for your other question, you first need to become familiar with the activity lifecycle and understand the novel meanings (almost meaninglessness) of common words like "open" and "start" in the life of an android app.
There isn't any way you can prevent the user from changing the system time - you just don't have the right to do that to users. Normally this should be a rare event, unless you do something that makes them want to, such as lock them out of a free version of your app after so many minutes. (However if the phone is on a mobile network, presumably the mobile network occasionally adjusts its time to correct for errors in the device's oscillator, or administrative time changes)
What you can do is check the system time on every entry point to your application. If it ever goes backwards, well... something is going on. If the clock has been set back, you could assume no time between the calls with the negative time difference and resume your time meter from there, at least keeping all the previous used time in your record.
It may be that there are cpu cycle counters which you could query and correlate to system time, but this may be highly device specific and may in fact be resettable. And it may get weird if the cpu frequency is demand throttled.
You might be able to set a countdown timer as a bound on the maximum possible time between entry points at which you could meter. I don't know if these work reliably across system time changes or not - ideally they would. Testing or reading the source will reveal.
Use elapsedRealtime in your onCreate() store it. More reliable.

Categories

Resources