Android Can only use lower 16 bits for requestCode

1
2
3
java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
...
...

context.startActivityForResultrequestCode 有对应限制

对应源码为

1
2
3
4
5
6
7
@Override
public void startActivityForResult(Intent intent, int requestCode) {
    if (requestCode != -1 && (requestCode&0xffff0000) != 0) {
      throw new IllegalArgumentException("Can only use lower 16 bits for requestCode");
    }
    super.startActivityForResult(intent, requestCode);
}