tags:

views:

74

answers:

3

Hello

In my android application I would like to block the user from changing the device time when my application is opened or minimised. The user should be able to change only once the app gets closed.

Please share your valuable suggestions.

Thanks in advance :)

+5  A: 
  1. Android applications do not get closed or minimized, they have different semantics. Please read up on the activity life cycle.

  2. Android applications do not get to block users from conducting other operations on the device.

Chris Stratton
Thanks Chris.Actually in my android app i would like to know how long is my app open so i thought i would take device time and by taking the difference i would get the time.So i dont want the user to change the time in the mean while.Any other way to get the time since the app is open?
Remmyabhavan
since you started another question for that, please see the answer over there
Chris Stratton
A: 

Hi teedyay,

buddy u cannot restrict user from changing his/her device time. better you can simply put your own counter.. as i understand you want to find the time for which your application has been up.. for that u can simply launch a thread synced with system clock pulse, and instead of relying on Systems time you can always go ahead and put up your own counter working as secondary milliseconds! :) There always a work around! Hope it helps!

Abhinava
+1  A: 

I would like to know how long is my app open so i thought i would take device time and by taking the difference i would get the time.

There is an API that will tell you how much time has passed since the device was booted, regardless of what the device clock is set to:

SystemClock.elapsedRealtime() "returns milliseconds since boot, including time spent in sleep."

Christopher