Is it possible in Android to get a time / date, which can not be manipulated by the user?
I mean in Android you can edit the system time and if you remove the battery the time is reseted too. Of course you can get the current time from a server on the internet but (improbable but is would work) then the user is able to intercept the request and send an own time back.
I do not know much about GPS. Is there a time stamp and is it possible that the user can replace it? I really want a time which can definitely not be changed by the user. Is that possible?
You can never trust the client. If this is really as absolutely crucial as you're saying, see if it's possible to offload whatever it is you're doing to a server that's under your control.
Related
I am developing an App, a simple, but hopefully addictive little game. The user has to solve predefined levels, as quick as possible.
Information on the levels is stored online in an MySQL database, which also contains the average time it took all players to complete a given level. Also, the level-data is stored, locally, in a SQlite database on the phone.
What I want to do is the following. I want to synchronize the average time (from server to phone) and upload the time it took a player to complete a leve (from phone to server).
Ideally this happens each time the player starts the app or finishes a level. For this, I am considering a Firebase Jobdispatcher, but I was wondering if this is overkill or not. For your information: it is not the end of the world if the average time stored on the phone is not entirely up to date. The game will work just fine without it being up to date. On the other hand, I want it to get updated regularly as the performance of the user will be compared to the average time.
I am a beginner, who wants to do things correctly. Hope you can help.
It sounds like you already know when some work should happen. As you said:
Ideally this happens each time the player starts the app or finishes a level.
You don't need JobDispatcher to schedule work when you are already in control of the times when the work should happen. JobDispatcher is used when you need to schedule some work at some point in time or interval when your app may not even be running.
Is there any way to get the results like in this link having wrong date and time set on device? Thank you.
There's a way1 ...
Suppose that you have deliberately set the clock 1 minute slow.
Create a file that contains the number 60,000. When an application wants to find the correct time, it calls System.getTimeMillis() to get what the system thinks the time is. Then reads the number from the file and adds that number to the result of System.getTimeMillis().
Clearly, this is NOT a good idea, but then neither is deliberately setting the system clock incorrectly. (For a start, if the clock is miss-set, then you will have difficulty syncing it with an external time source like an NTP server. That means that your system's clock will drift.)
The problem i am working on is the TOTP algorithm. The thing I was wondering is how would it work if the time on server and the one on the device are not the same.
I see. The answer is that TOTP cannot work if the two clocks are not synchronized to within a small multiple of the timestep.
1 - There's another way too. Write an application that can do some image processing on a picture of a clock to read the time. Then hook this up to your computer's video camera, and point the camera at a cuckoo clock hanging on your wall. Make sure you wind up the clock regularly. If you want the date as well, point a second video camera at your Dilbert desk calendar.
I am trying to license my product(java app) with a simple technique by comparing two dates.I want to know how should I increment the date when I give the app to my client.I need to increment the date everyday,so that when it expires it doesnt work.
I dont want to use the system date,cause there are chances the client might change that.So could anyone provide me any suggestions.
Since the java app is going to be running on your client, you have basically two options (simplistically speaking).
Option1. Use a (possibly) encrypted file on your client's filesystem to store the date you want to store and compare against your expire date.
Option2. Upon registering, register to a server. Now the server knows when you registered, so it should be able to determine when you expire. Each time the application starts, make a call to the server asking if it has expired. This way, you have transferred part of the expiry logic to the server.
Keep in mind that both approaches in their simplistic form can be easily circumvented but that is most of the time the case when you have an app running on clients' computers.
One way i can think of is
Use webservice to get current date in your client
earthtools.org provides a free web service to get the time zone from a city here:
http://www.earthtools.org/webservices.htm#timezone
You just pass in the long/lat values like this: (This is for New York)
http://www.earthtools.org/timezone-1.1/40.71417/-74.00639
Use java Rest client to get date in your code
http://www.mkyong.com/webservices/jax-rs/restfull-java-client-with-java-net-url/
I have managed to read the web service to get current time of any given city.
I could get 2 important values from web service, current time (String) and the offset.
Question is
How to set time of any given city correctly?
Option 1:
Read machine/local time
Calculate UTC/GMT time out of machine time
City time = UTC time +/- offset value
But then what happens when machine time is wrong? You will also got
wrong time right?
Option 2:
Read current city time in String (2012-11-24 19:30)
Parse this time value and set it into Calendar
We got correct City time
But how about the next minute? Of course requesting the web service every minute to get current time is not a good solution right? Is it possible to maintain this Calendar instance keep running automatically every minute once we set it?
NB : I'm developing Android clock widget here.
Thanks
Option 1 is far better, in my eyes. Most cell phones have amazingly accurate time as time synchronization is an integral part of GSM and CDMA. Beyond that, I would far prefer a clock to work offline than to require internet connectivity.
If you are worried about ensuring accuracy in the face of incorrect system time, consider placing a call to a web service to get the current time for verification.
This verification could be done in the background, but keep in mind that web services are not the best time sync providers. I would let anything with under 5 minute difference go as it could be due to your server being out of sync or the call taking too long.
I'm playing around with OSCeleton and Processing and succesfully got to track skeletons and do stuff.
What I'm wondering is if there's any way to change the delay time a "lost_user" message is sent to Processing.
This is taking so long for what I'm trying to achive, since i need to stop tracking a user as soon as he goes away from the screen, so I can accept another user's interaction. (imagine an installation where a lot of people wants to play with).
any help/tips would be really appreciated.
Jon
As far as I can tell from the OSCeleton's source and with my minimal experience with the kinect(I never used OSCeleton), there is no way to modify that code to do that. It seems to be a thing handled even lower, by the driver or by the kinect its self(?).
Yet you need not bind yourself with that, and I would suggest a couple of ways to bypass the problem if I understand properly.
First, the latest drivers and examples should have multi-user support, meaning you can just arrange who is your main user. From what I can tell from the source you do get an osc message in Processing when a new user is detected as well as an ID number. You can put each new user that arrives, into an arrayList and figure out a way to do things without depending on the latest user.
If you are still going for the user-after-user thing though, or I was mistaken about the multi-user support(which is mentioned nowhere in the README), you can check yourself whether a user has left the area. Although you can not get a definitive answer like that you can check for example, whether a specific joint or all joints of a user have moved in the last 10-20 osc messages received. That probably means storing the position of this joint in an 10-20 item array and continuously updating while also doing a check on whether the items are different. If all items in the array are the same, your user has not moved a bit and thus probably should not be taken to account.
Last but not least you can switch to other solutions. The one I used about a year ago was "Synapse for Kinect" which also seems stale now. The latest you can use is a Processing library called SimpleOpenNI which definitively have multi-user tracking and you won't need any intermediary programs running to give you the joints.
I hope this helps