Issue
I need to get layout name of any activity from activity life cycle method.
override fun onActivityStarted(activity: Activity) { Log.d("onActivityStarted", activity.localClassName) }
Solution
I found a solution for this first get view group of your activity like this
val viewGroup = (activity.findViewById(android.R.id.content) as ViewGroup).getChildAt(0) as ViewGroup
then get resources id and by the resources id get resources name like this
val resourceName = activity.resources.getResourceName(viewGroup.sourceLayoutResId)
thats it you have your attached layout path and name with your activity
Log.d("Layout res path", ">>>>>> $resourceName")
Answered By - Atul Papneja
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.