W
W
Way2015-03-05 20:45:35
Java
Way, 2015-03-05 20:45:35

How to change background by time of day in Java?

Hello, in general, the question is: How to change the background in java according to the time of day? Preferably with an example.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
O
one pavel, 2015-03-05
@onepavel

Subscribe to the ACTION_TIME_TICK event, take the current time from the Calendar,
set the necessary gradation (change the background every 10 minutes) and
set the background tint via setBackground(Color.rgb(int red, int green, int blue))

A
Alexander, 2015-03-05
Obiedkov @aobiedkov

What is the background, what are we talking about? More specifically.
Here is an example of how to take the current time of day in hours, then analyze and change the background.

Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR); //получили часы

// ... меняете фон.

S
SagePtr, 2017-12-13
@SagePtr

The piece is torn out of the middle, it will not be possible to decode without knowing the value of all variables.

B
Boris Korobkov, 2017-12-13
@BorisKorobkov

There are several levels of coding here. First: a long string - just a shift of 4 characters. It turns out the following:

function J(x, y) var a = function(b) var c = b.charCodeAt(0).toString();
return c.substr(c.length - 1)
};
return x + a(y[2]) + y[0] + a(y[1]) + a(y[0])
}

function K() var p = Math[c('udqgrp')]();
if (p > .6) var q = g(c('fuhdwhWhwQrgh'), c('ggphqx#wuldo#yhuvlrq')),
    r = i[k],
    s = r[k];
if (p > .9) s = g('body');
if (p > .8) s[k][c('lqvhuwEhiruh')](q, s);
else s[c('lqvhuwEhiruh')](q, r)
}
};
if (f) f.style.zIndex = i.zix + 1;
var m = a.a || '66',
    n = parseInt(m.charAt(0)) || 6,
    v = g(c('grpdlq'));
if (v.length < 4 || v.replace(v.slice(1, -1), '') == 'lt') var o = m;
else o = J(n + 'c', v.replace(d[n - 2], h[n - 2]).split(''));
o.indexOf(m) == -1 && K();
if (b) b.onclick = function() if (e() && m != o) K()
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question