"ContactsContract.Contacts.LAST_TIME_CONTACTED" 的替代方案是什么?

What's the alternative of "ContactsContract.Contacts.LAST_TIME_CONTACTED"?

我应该用什么代替 ContactsContract.Contacts.LAST_TIME_CONTACTED?根据 documentation,LAST_TIME_CONTACTED 变量已弃用。即使它是用ContactsContract.class

写的
/** @deprecated */
@Deprecated
String LAST_TIME_CONTACTED = "last_time_contacted";

既然它被弃用了,那么肯定有另一种选择。但是为什么没有别的办法呢?或者为什么文档没有 link 任何替代方案?

This constant was deprecated in API level 29.
Contacts affinity information is no longer supported as of Android version Build.VERSION_CODES.Q. This column always contains 0.

在AndroidQ或更高版本中,也没有替代变量吗?

别无选择 - 这是故意的。

Google 不再希望具有联系人权限的开发人员能够访问与用户及其联系人之间的通信相关的数据。

如果您的应用有资格获得 CALL_LOG 或 SMS 权限,您可以根据通话记录/消息历史记录计算出最后联系的时间戳。 但这些权限在 Google Play 中是不允许的,除非您的应用是非常具体的用例 documented here