• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps nanoTime() method output

amirihana

Newbie
i am using nanoTime() as timestamps to create an interval to execute a certain method like this:

Code:
long start=System.nanoTime();
		Log.d("time", "time "+start);
		Log.d("time", "time "+start/1000000);

		while(true)
		{
			long end=System.nanoTime();
			Log.d("end", "end "+end);
			Log.d("end", "end "+end/1000000);

			if(end>=start+number)
			{
				method();
				start=end;
			}

		}
i want my loop (number) to be every 5 seconds. Considering that 1 millisecond is equal to 1000000 nanoseconds, i thought i should add 1000 000 000 as number, but it wasn't correct.
My problem is i cannot interpret the nanoTime() output. i dont want to convert for precision issues.
 
Back
Top Bottom