Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

how to get Activity's windowToken without view?

I faced exactly the same problem, while writing OnPageChangeListener within an Activity. You can use one of these solutions. Either:

getWindow().getDecorView().getRootView().getWindowToken()   

or:

findViewById(android.R.id.content).getWind‌​owToken()

Surely you can use:

getContentView().getWindowToken()

or you can refer to SO Quest


Simply use getWindow().getDecorView().getWindowToken()

Tags:

Android

Android Activity

Related

When is static cast safe when you are using multiple inheritance? Is there an aggregate function that could return first non-null value within a group? javascript looping and deleting object properties Rails keeps telling me that it's not currently installed UIPageViewController Gesture recognizers Using JQuery to Access a New Window's DOM LEFT JOIN order and limit Java - Cast a Map The role of -supportsWeakPointers CSS selector for other than the first child and last child CMake : How to get the name of all subdirectories of a directory? adding bounce effect to appearance of UIImageView

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy