We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我是在一个全局悬浮窗里面添加的这个组件,所以没有 Activity,当开始拖动时,报错:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? at android.view.ViewRootImpl.setView(ViewRootImpl.java:798) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93) at com.xw.repo.BubbleSeekBar$7.onAnimationStart(BubbleSeekBar.java:1020) at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationStart(ViewPropertyAnimator.java:1090) at android.animation.Animator$AnimatorListener.onAnimationStart(Animator.java:536) at android.animation.ValueAnimator.notifyStartListeners(ValueAnimator.java:1013) at android.animation.ValueAnimator.startAnimation(ValueAnimator.java:1262) at android.animation.ValueAnimator.start(ValueAnimator.java:1064) at android.animation.ValueAnimator.start(ValueAnimator.java:1088) at android.view.ViewPropertyAnimator.startAnimation(ViewPropertyAnimator.java:904) at android.view.ViewPropertyAnimator.start(ViewPropertyAnimator.java:416) at com.xw.repo.BubbleSeekBar.showBubble(BubbleSeekBar.java:1022) at com.xw.repo.BubbleSeekBar.onTouchEvent(BubbleSeekBar.java:695)
The text was updated successfully, but these errors were encountered:
主要变更:
if (context instanceof Application) { // 使用全局悬浮窗 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { mLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; } } else { // MIUI禁止了开发者使用TYPE_TOAST,Android 7.1.1 对TYPE_TOAST的使用更严格 if (BubbleUtils.isMIUI() || Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION; } else { mLayoutParams.type = WindowManager.LayoutParams.TYPE_TOAST; } }
Sorry, something went wrong.
No branches or pull requests
我是在一个全局悬浮窗里面添加的这个组件,所以没有 Activity,当开始拖动时,报错:
The text was updated successfully, but these errors were encountered: