1

Android Docs say in about ID XML resource:

A unique resource ID defined in XML. [...] which you can use as [...] unique integer for use in your application code (for example, as an ID for a dialog or a result code).

I created request in ids.xml

<item name="request" type="id" />

Its value is -1000003. I want to use it as requestCode for startActivityForResult from FragmentActivity. But as it is described here, requestCode must be of 16 bits, meaning the range is from 0 to 65535. So the value of request is not valid (it is negative and also exceeds bounds range). and using it causes this error:

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

Although I can use arbitrary valid integer, but its uniqueness may be violated during time of application maintaining/developing. Is there a way to solve this problem?

hasanghaforian
  • 13,858
  • 11
  • 76
  • 167

1 Answers1

0

Your value is a negative number but range is of positive numbers only. This error is might be because of this reason

Kartika Vij
  • 203
  • 3
  • 17