小弟不才,对安卓这方面了解不是很深
https://github.com/msg555/PowerTutor/blob/src/edu/umich/PowerTutor/componentsAudio.java
这是几年前的 powertutor 的代码,audio 用来获取音频设备信息,不过
public int uid; public int id; public int assignUid; public int compareTo(Object obj) { MediaData x = (MediaData)obj; if(uid < x.uid) return -1; if(uid > x.uid) return 1; if(id < x.id) return -1; if(id > x.id) return 1; return 0; } public boolean equals(Object obj) { MediaData x = (MediaData)obj; return uid == x.uid && id == x.id; }
}
请问为什么要比较呢?是用来确定读写权限的嘛?现在是不是又比这个更简单的实现?
![]() | 1 xupefei 2015-03-24 03:05:44 +08:00 http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html#compare(T,%20T) 说: Return: a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. 返回 -1 和返回 -10086 一样,1 和 10010 也一样。 |