尝试在空对象引用上调用虚方法’void android.widget.Editor $SelectionModifierCursorController.hide()’
作者:互联网
这个错误似乎只发生在使用Android 6.0.1的三星手机上.或7.0:
Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'void android.widget.Editor$SelectionModifierCursorController.hide()' on a null object reference
android.widget.Editor.performLongClick (Editor.java:1139)
android.widget.TextView.performLongClick (TextView.java:10945)
android.view.View$CheckForLongPress.run (View.java:22568)
android.os.Handler.handleCallback (Handler.java:739)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:7325)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
寻找一种方法来防止它. =)
这似乎是一个已知问题,但优先级较低:
Issue 228485: SelectionModifierCursorController.hide()’ on a null object reference
解决方法:
对我来说,最简单的解决方案是在EditText中覆盖此方法.希望三星有一天会修复它.
override fun performLongClick(): Boolean {
try {
return super.performLongClick()
} catch (e: NullPointerException) {
return true
}
}
override fun performLongClick(x: Float, y: Float): Boolean {
try {
return super.performLongClick(x, y)
} catch (e: NullPointerException) {
return true
}
}
标签:android,samsung-mobile,android-7-0-nougat,android-6-0-1-marshmallow 来源: https://codeday.me/bug/20190710/1428770.html