Last active
August 16, 2016 00:00
-
-
Save twiceyuan/25fa82acdeffd78e345bee562ccefb5b to your computer and use it in GitHub Desktop.
获取全局唯一的整形常量,可以用于 requestCode 的定义,防止其在不同文件中定义时值的碰撞。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RequestCode { | |
private static final AtomicInteger seed = new AtomicInteger(); | |
public static int get() { | |
return seed.incrementAndGet(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final int REQUEST_CODE = RequestCode.get(); | |
public void doSomething() { | |
startActivityForResult(intentA, REQUEST_CODE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment