我尝试这个SDK
implementation 'com.google.android.libraries.places:places:1.1.0'
这是我的代码
if (!Places.isInitialized()) {
Places.initialize(getApplicationContext(), "YOUR_API_KEY");
}
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME);
// Start the autocomplete intent.
Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.FULLSCREEN, fields)
.build(this);
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
这是我的原木猫
2019-05-21 17:21:52.921 13555-13555/com.pripun.ecom D/ViewRootImpl@50aa60a[Transaction]: ViewPostIme pointer 0
2019-05-21 17:21:53.076 13555-13555/com.pripun.ecom D/ViewRootImpl@50aa60a[Transaction]: ViewPostIme pointer 1
2019-05-21 17:21:53.172 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: setView = DecorView@97eb784[AutocompleteActivity] TM=true MM=false
2019-05-21 17:21:53.172 13555-13555/com.pripun.ecom D/ViewRootImpl@50aa60a[Transaction]: MSG_WINDOW_FOCUS_CHANGED 0
2019-05-21 17:21:53.175 13555-13555/com.pripun.ecom V/InputMethodManager: Not IME target window, ignoring
2019-05-21 17:21:53.177 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: dispatchAttachedToWindow
2019-05-21 17:21:53.187 13555-13555/com.pripun.ecom V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
2019-05-21 17:21:53.187 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: Relayout returned: old=[0,0][0,0] new=[0,0][1080,1920] result=0x7 surface={valid=true 547448614912} changed=true
2019-05-21 17:21:53.194 13555-13602/com.pripun.ecom D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000, [1080x1920]-format:1
2019-05-21 17:21:53.194 13555-13602/com.pripun.ecom D/OpenGLRenderer: eglCreateWindowSurface = 0x7f8a0190b0
2019-05-21 17:21:53.216 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
2019-05-21 17:21:53.217 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: MSG_WINDOW_FOCUS_CHANGED 1
2019-05-21 17:21:53.232 13555-13555/com.pripun.ecom V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@6a3d76 nm : com.pripun.ecom ic=com.android.internal.widget.EditableInputConnection@b3a4f77
2019-05-21 17:21:53.233 13555-13555/com.pripun.ecom I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
2019-05-21 17:21:53.262 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: MSG_RESIZED: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 750) vi=Rect(0, 72 - 0, 750) or=1
2019-05-21 17:21:53.263 13555-13555/com.pripun.ecom W/View: dispatchProvideAutofillStructure(): not laid out, ignoring
2019-05-21 17:21:53.264 13555-13555/com.pripun.ecom I/chatty: uid=10658(u0_a658) com.pripun.ecom identical 3 lines
2019-05-21 17:21:53.264 13555-13555/com.pripun.ecom W/View: dispatchProvideAutofillStructure(): not laid out, ignoring
2019-05-21 17:21:53.265 13555-13555/com.pripun.ecom I/AssistStructure: Flattened final assist data: 2272 bytes, containing 1 windows, 10 views
2019-05-21 17:21:53.266 13555-13555/com.pripun.ecom W/IInputConnectionWrapper: performPrivateCommand on inactive InputConnection
2019-05-21 17:21:53.268 13555-13565/com.pripun.ecom I/zygote64: Do partial code cache collection, code=1009KB, data=632KB
2019-05-21 17:21:53.269 13555-13565/com.pripun.ecom I/zygote64: After code cache collection, code=1009KB, data=632KB
2019-05-21 17:21:53.269 13555-13565/com.pripun.ecom I/zygote64: Increasing code cache capacity to 3MB
2019-05-21 17:21:53.274 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=true 547448614912} changed=false
2019-05-21 17:21:53.316 13555-13555/com.pripun.ecom D/ViewRootImpl@50aa60a[Transaction]: MSG_RESIZED: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 873) vi=Rect(0, 72 - 0, 873) or=1
2019-05-21 17:21:53.317 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: MSG_RESIZED: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 873) vi=Rect(0, 72 - 0, 873) or=1
2019-05-21 17:21:53.338 13555-13555/com.pripun.ecom D/ViewRootImpl@50aa60a[Transaction]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=true 547475845120} changed=false
2019-05-21 17:21:53.352 13555-13555/com.pripun.ecom D/ViewRootImpl@4503997[AutocompleteActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=true 547448614912} changed=false
我在Google Places上尝试了此最新代码,但地图并非仅显示空白,而是自动完成功能正在运行。 Link
答案 0 :(得分:0)
请注意,地点选择器自2019年1月29日起已过时。此功能将在2019年7月29日关闭,在该日期之后将不再可用。请注意,使用iOS / Android上的Places SDK的旧用户是唯一在弃用期间仍可以使用Place Picker的用户。现在已通过启用Places API在两个平台上使用Places SDK,并且不再支持使用Place Picker。您可能会在https://developers.google.com/places/android-sdk/placepicker中看到弃用通知。
除此之外,Google正在对促使用户使用位置选择器的因素进行审查,如果您有兴趣,请以本期(Android)issuetracker.google.com/128304810中提到的形式添加您的答案,(iOS)issuetracker.google.com/128304760。