在 8.0 以下启动新的 activity 没问题, 但在 8.0 系统的手机上就报错, 跳转不成功
错误原因:
目标 activity 中有如下方法
- public int getUserId() {
- }
其父类 Context.java 里也有该方法 同名了
- /**
- * Get the userId associated with this context
- * @return user id
- *
- * @hide
- */
- @TestApi
- public abstract @UserIdInt int getUserId();
导致系统无法判断是用 Context 里面的还是你自己的
解决办法:
把该 activity 中的方法改名 (例如: getLocalUserId()) 或者修改该 getUserId()为 private, 即可.
来源: http://www.bubuko.com/infodetail-2848247.html