8.0之后 java.lang.SecurityException: Permission Denial: null asks to run as user 864 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERA

在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,即可

原文地址:https://www.cnblogs.com/evolutionoflicorice/p/9964888.html