How to implement ViewTreeObserver.OnWindowFocusChangeListener in a service in Android . The code does not show any type of error when i use it in my java file . Is there any other way to use OnWindowFocusChangeListener in a service ? Please help me. Thanks in advance !!
Do it like this way
WindowManager windowManager=(WindowManager)getSystemService(WINDOW_SERVICE);
LayoutInflater inflater=
(LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
RelativeLayout layout=(RelativeLayout) inflater.inflate(R.layout.box,null);
You need a WindowManager.LayoutParams object which should contain the parameters for the layout
windowManager.addView(layout,params);
now add ViewTreeObserver.OnWindowFocusChangeListener on your desired view.