I am working on an app in which I have to get all the views of the top most activity. This activity may or may not be of my app.
I am able to get all the views from a ViewGroup(root view)
.
Now I just want to get the root view of top most activity to do my work but I was not able to find any answers which gives me an idea to get root view of an activity from service.
I had used these methods:
View rootView = Window.DecorView.RootView;
and
Context ctx = this;
ViewGroup rootView = ((Activity)ctx).getWindow().getDecorView().findViewById(android.R.id.content);
But nothing works inside service class.
It reports that getWindow()
and findViewById
() did not work inside android service class.
So I just want to know is there any other way to do the same?
Thanks In Advance...:-)