发布 Google 地点自动完成响应 - 现在声明为内部
Release Google Places Autocomplete Response - now declared as internal
最近将 Google API 版本从 11.8.0 升级到 12.0.1 导致我的 Task<AutocompletePredictionBufferResponse>
完成侦听器中的 task.result.release()
被标记为内部。
我是否应该以不同方式处理内部数据泄露的可能性? Google Places API 现在是否处理发布结果本身?我在 release notes for 12.0.0 or 12.0.1. The current documentation still says you must release the result.
中找不到相关信息
这里是我使用它的地方:
.addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
if (task.isSuccessful) {
{...}
//Release to avoid internal data leak
task.result.release()
} else {
Log.e("AutoCompletePredictions", task.exception?.message)
//Release to avoid internal data leak
task.result.release()
}
}
.addOnFailureListener(this@NewLocationActivity) {
Log.e("AutoCompletePredictions", it.message)
}
这是我收到的错误消息:
zzb.release is marked as internal and should not be accessed from apps less... (⌘F1)
This API has been flagged with a restriction that has not been met. Examples of API restrictions: * Method can only be invoked by a subclass * Method can only be accessed from within the same library (defined by the Gradle library group id) .* Method can only be accessed from tests. . You can add your own API restrictions with the @RestrictTo annotation.
我使用完成侦听器的完整 getSuggestions()
方法
private fun getSuggestions() {
val filter = AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.setCountry(CountryManager.getCountryISO())
.build()
Places.getGeoDataClient(this@NewLocationActivity/*, null*/) // uncomment for v11.8.0
.getAutocompletePredictions(
activity_new_location_edit_text.text.toString(),
null,
filter
)
.addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
if (task.isSuccessful) {
val addressList: ArrayList<String> = arrayListOf()
var index = 0
for(item in task.result) {
if(index >= MAX_SUGGESTION_RESULTS)
break
addressList.add(item.getFullText(null).toString())
index++
}
if(!(addressList.size == 1 && addressList[0] == activity_new_location_edit_text.text.toString()))
loadGoogleAddressesIntoSuggestionList(addressList)
//Release to avoid internal data leak
task.result.release()
} else {
Log.e("AutoCompletePredictions", task.exception?.message)
//Release to avoid internal data leak
task.result.release()
}
}
.addOnFailureListener(this@NewLocationActivity) {
Log.e("AutoCompletePredictions", it.message)
}
}
似乎是意外更改。
它从 12.0.0 开始,在其 release notes 中有以下 "known issue":
An annotation causes spurious lint errors claiming GoogleSignIn
and
CredentialsClient
are internal-only. These can safely be ignored.
猜想他们不仅针对 GoogleSignIn
和 CredentialsClient
,而且他们只修复了 12.0.1:
中的那些
Fixes issue that caused spurious Android lint errors claiming
GoogleSignIn
and CredentialsClient
were internal-only.
release()
的相应源代码在 11.8.0-12.0.1 版本中似乎是相同的,因此我相信您可以放心地忽略这些警告。
最近将 Google API 版本从 11.8.0 升级到 12.0.1 导致我的 Task<AutocompletePredictionBufferResponse>
完成侦听器中的 task.result.release()
被标记为内部。
我是否应该以不同方式处理内部数据泄露的可能性? Google Places API 现在是否处理发布结果本身?我在 release notes for 12.0.0 or 12.0.1. The current documentation still says you must release the result.
中找不到相关信息这里是我使用它的地方:
.addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
if (task.isSuccessful) {
{...}
//Release to avoid internal data leak
task.result.release()
} else {
Log.e("AutoCompletePredictions", task.exception?.message)
//Release to avoid internal data leak
task.result.release()
}
}
.addOnFailureListener(this@NewLocationActivity) {
Log.e("AutoCompletePredictions", it.message)
}
这是我收到的错误消息:
zzb.release is marked as internal and should not be accessed from apps less... (⌘F1) This API has been flagged with a restriction that has not been met. Examples of API restrictions: * Method can only be invoked by a subclass * Method can only be accessed from within the same library (defined by the Gradle library group id) .* Method can only be accessed from tests. . You can add your own API restrictions with the @RestrictTo annotation.
我使用完成侦听器的完整 getSuggestions()
方法
private fun getSuggestions() {
val filter = AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.setCountry(CountryManager.getCountryISO())
.build()
Places.getGeoDataClient(this@NewLocationActivity/*, null*/) // uncomment for v11.8.0
.getAutocompletePredictions(
activity_new_location_edit_text.text.toString(),
null,
filter
)
.addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
if (task.isSuccessful) {
val addressList: ArrayList<String> = arrayListOf()
var index = 0
for(item in task.result) {
if(index >= MAX_SUGGESTION_RESULTS)
break
addressList.add(item.getFullText(null).toString())
index++
}
if(!(addressList.size == 1 && addressList[0] == activity_new_location_edit_text.text.toString()))
loadGoogleAddressesIntoSuggestionList(addressList)
//Release to avoid internal data leak
task.result.release()
} else {
Log.e("AutoCompletePredictions", task.exception?.message)
//Release to avoid internal data leak
task.result.release()
}
}
.addOnFailureListener(this@NewLocationActivity) {
Log.e("AutoCompletePredictions", it.message)
}
}
似乎是意外更改。
它从 12.0.0 开始,在其 release notes 中有以下 "known issue":
An annotation causes spurious lint errors claiming
GoogleSignIn
andCredentialsClient
are internal-only. These can safely be ignored.
猜想他们不仅针对 GoogleSignIn
和 CredentialsClient
,而且他们只修复了 12.0.1:
Fixes issue that caused spurious Android lint errors claiming
GoogleSignIn
andCredentialsClient
were internal-only.
release()
的相应源代码在 11.8.0-12.0.1 版本中似乎是相同的,因此我相信您可以放心地忽略这些警告。