-
Notifications
You must be signed in to change notification settings - Fork 15
Hardcoded activity result identifiers #46
Copy link
Copy link
Open
Description
Prefer not to use hardcoded identifiers for activity results:
Lines 35 to 38 in 88b0ae3
| companion object { | |
| const val REQUEST_CODE_OPEN_FILE = 40832 | |
| const val REQUEST_CODE_CREATE_FILE = 40833 | |
| } |
Use IDs in res/values/ids.xml instead. That way, you can avoid any possible collision because the compiler toolchain will generate unique IDs even if the app has its own and the plugins it relies on also have their own.
It's as simple as:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="some_request_name" type="id" />
</resources>and then using it:
activity.startActivityForResult(intent, R.id.some_request_name and 0xFFFF)You're free to and it with 0xFFFF, the unique ID is in the lower word and startActivityForResult() expects a 16-bit value, anyway.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels