The proof follows from lemma 2 given by XIADO : Here is a simplified proof
Proof of Lemma 1:
It suffice to prove it for some measurable $ B \subset A $ and $ B\subseteq I=[a ,b]$ and $ m (B) > 0,|a|,|b| > 0$:
There some measurable $ S$ with $ m (S) > 0$ and by Lebesgue density theorem there some $ x \in S \subseteq I $ and some $ 0<r<\frac{m(I)}{2},1>\epsilon > 0$ such that $ I_r=(x-r, x+r)$, $ m (S \bigcap I_r) > (1-\epsilon)m (I_r)$
It also obvious that for $ S_q =q\cdot S $, $ I_{r, q}=q\cdot I_r $,$ m(S_q)=qm (S) , m(I_{r, q})=qm (I_r) $, and $ (S_q\bigcap I_{r, q}) >q (1-\epsilon)m (I_r)$ ,where $q \in \mathbb {Q} $
Now we can take subsequence {$ I_{r, q} $}that is pairwise disjoint such that $\bigcup_q I_{r, q} \supseteq I $ and $max${$|q|$} $\le n^2,n^2=\frac {|b|}{|a|}$
Define $ B = S \bigcap I_r $ , $ B_q=q\cdot B $, It follows $ m(\bigcup_q B_{q}) >(1-\epsilon)m (I)$
$ m(I-\bigcup_q B_{q}) = m (I) - m ( I\bigcap\bigcup_q B_{q}) $
$ m(I-\bigcup_q B_{q}) \le \epsilon m (I)+ 2rn^2 $
$A_q=q\cdot A$
$ I- \bigcup_q A_q \subseteq I-\bigcup_q B_{q} $
Therefore $ m(I-\bigcup_q A_q) \le \epsilon m (I)+2rn^2 $
Letting $r,\epsilon \to 0$ the result follows
Proof of Lemma 2
define $A=${$x \in \mathbb{R} : f(x) < r$}
$m(q\cdot A-A)=0$ since $f(qx)=f(x)$ ae
so if $m(A) >0$ ,since $ m(I-\bigcup_q A_q)=0$
It follows $f(x) < r$ ae, hence it is bounded almost everywhere and so it is locally integrable
Using the result of see here shows $ f (x) $ is constant ae on $(0, \infty)$