hbb20 / hbb20/CountryCodePickerProject

Unable to add window -- token null is not valid; is your activity running?

Open
#609 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.5k
Forks
509
PR merge metrics
No merged PRs in 30d

Description

`Process: com.example.android, PID: 10996
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:907)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:387)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
at android.app.Dialog.show(Dialog.java:342)
at com.hbb20.CountryCodeDialog.openCountryCodeDialog(CountryCodeDialog.java:265)
at com.hbb20.CountryCodePicker.launchCountrySelectionDialog(CountryCodePicker.java:2207)
at com.hbb20.CountryCodePicker.launchCountrySelectionDialog(CountryCodePicker.java:2199)
at com.hbb20.CountryCodePicker$1.onClick(CountryCodePicker.java:147)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)`

We are use ViewPager with custom view without fragment

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with CountryCodeDialog.openCountryCodeDialog and the CountryCodePicker.launchCountrySelectionDialog call path shown in the stack trace. Reproduce the failure with the library used inside a ViewPager and a custom view without a fragment, then inspect how the dialog obtains its activity context. Done means country selection opens without the BadTokenException in that setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.