Takt icon indicating copy to clipboard operation
Takt copied to clipboard

FPS text only shows for a few seconds (then disappears) in Android 7.1

Open arshcaria opened this issue 6 years ago • 3 comments

Google changed the behavior of LayoutParams.TYPE_TOAST in Android 7.1. https://android.googlesource.com/platform/frameworks/base/+/dc24f93

So on 7.1 devices the FPS text cannot not stay on the screen.

arshcaria avatar Jul 27 '17 08:07 arshcaria

You can add version check as follow,and it will wrok well.

    if(  Build.VERSION.SDK_INT <21) {
      params.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
    }else if( Build.VERSION.SDK_INT <24) {
      params.type = WindowManager.LayoutParams.TYPE_TOAST;
    }else {
      params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
    }
  

Leon406 avatar Nov 25 '17 04:11 Leon406

catch exception when loading tinker:java.lang.RuntimeException: Unable to create application com.tencent.radio.RadioApplication: android.view.WindowManager$BadTokenException: Unable to add window -- window android.view.ViewRootImpl$W@8ca0794 has already been added at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5406) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- window android.view.ViewRootImpl$W@8ca0794 has already been added at android.view.ViewRootImpl.setView(ViewRootImpl.java:691) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93) at jp.wasabeef.takt.Takt$Program.play(Takt.java:113) at com.tencent.radio.RadioApplicationDelegate.initTakt(RadioApplicationDelegate.java:122) at com.tencent.radio.RadioApplicationDelegate.onCreate(RadioApplicationDelegate.java:111) at com.tencent.tinker.loader.app.TinkerApplication.onCreate(TinkerApplication.java:173) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403) at android.app.ActivityThread.-wrap2(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6119)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

Fengcoder avatar Dec 06 '17 06:12 Fengcoder

7.1.1 直接crash了

Fengcoder avatar Dec 06 '17 06:12 Fengcoder